基本信息
源码名称:C++实现ASE加密文件
源码大小:4.49M
文件格式:.rar
开发语言:C/C++
更新时间:2019-07-03
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
用AES加密文件,语音是C ,无界面
/*
* 加密 right
*/
int Aes::encode()
{
//打开文件
ifstream fileRd(filePath, ios::binary);
ofstream fileWt("D:\\encode.txt", ios::binary);
if(fileRd.fail()||fileRd.fail()){//打开失败
fileRd.close();
fileWt.close();
cout<<"111";
return FILEOPENERROR;
}
cout<<"加密内容放在D:\\encode.txt中\n";
unsigned char buf[16];//取文件内容
unsigned char state[4][4];//运算状态
unsigned char enCdText[16];//加密后的数据
int t = 0; //计数器
int i,j;
int col,row;
bool glap = false;
while(!fileRd.eof())
{
glap = false;
memset(buf,0x00,16*sizeof(char));//清空buf
fileRd.read((char *)buf, sizeof(buf));
//cout<<buf<<endl;
for(i=0 ; i<16 ; i )
if(buf[i] != 0x00){
glap = true;
break;
}
if(!glap)break;
//buf转化为state
for(col=0 ; col<4 ; col )
for(row=0 ; row<4 ; row )
state[row][col] = buf[row col*4];
//addRoundkey 第一轮
addRoundKey(state, roundKey[0]);
//9轮
for(i=1 ; i<=9 ;i ){
subBytes(state);
shiftRows(state);
mixColumns(state);
addRoundKey(state, roundKey[i]);
}
//最后一轮
subBytes(state);
shiftRows(state);
addRoundKey(state, roundKey[10]);
//state 转化为 密文串
t = 0;
for(i=0;i<4;i ){
for(j=0;j<4;j ){
enCdText[t ] = state[j][i];
}
}
for(i=0 ; i<16 ; i )
fileWt.put(enCdText[i]);
}
fileRd.close();
fileWt.close();
return 0;
}