新手求助,EAS加密文件
「已注销」 2017-12-03 06:22:26
#include "AES.h"
#include "stdafx.h"
#include <string>
#include <windows.h>
#include <iostream>
#include <fstream>
#define PVFKEY "DD1DF9FB1895F9139D36571012092B70" //KEY,必须32位长度,不要有特殊字符
using namespace std;
int CopyFile(char *SourceFile,char *NewFile)
{
ifstream in;
ofstream out;
in.open(SourceFile,ios::binary);//打开源文件
if(in.fail())//打开源文件失败
{
cout<<"Error 1: Fail to open the source file."<<endl;
in.close();
out.close();
return 0;
}
out.open(NewFile,ios::binary);//创建目标文件
if(out.fail())//创建文件失败
{
cout<<"Error 2: Fail to create the new file."<<endl;
out.close();
in.close();
return 0;
}
else//加密文件
{
//AES aes;
//aes.setMode((unsigned char*)(PVFKEY), 32, 16, true);
//aes.invCipher((unsigned char*)out, (unsigned char*)out);
out<<in.rdbuf();
out.close();
in.close();
return 1;
}
}
void main()
{
char curPath[MAX_PATH];
char a[MAX_PATH]="\\Script.pvf";
char b[MAX_PATH];
char c[MAX_PATH]="\\Script_Encryption.pvf";
char d[MAX_PATH];
GetModuleFileNameA(NULL,curPath,MAX_PATH);
string tmp=curPath;
tmp=tmp.substr(0,tmp.find_last_of('\\'));
strcpy(b,tmp.c_str()); //把串a复制到有足够空间的c中
strcat(b,a); //当前文件目录
strcpy(d,tmp.c_str()); //把串a复制到有足够空间的c中
strcat(d,c); //加密后的文件路径
//cout<<b<<endl;
//cout<<d<<endl;
if(CopyFile(b,d))
{
cout<<"加密成功..."<<endl;
}
else
{
cout<<"加密失败..."<<endl;
}
}
红字部分错误,数据类型搞不懂。。
有人可以教我怎么改吗?谢谢。