#include "stdafx.h"
#include "des.h"
#define _crt_secure_no_warnings
#include #include #include #pragma warning(disable:4996)
int filesymenc(const char *pfile1,const char *pfile2);
int cryptlen = 0;
fp1 = fopen(pfile1,"rb");
if (fp1 == null)
fp2 = fopen(pfile2,"wb");
if (fp2 == null)
//檔案開啟了,要拷貝資料了
while (!feof(fp1))
//加密==4k的資料
ret = desenc_raw(plain, plainlen, cryptbuf, &cryptlen);
if (ret != 0)
plainlen2 = fwrite(cryptbuf, 1, cryptlen, fp2);
if (plainlen2 != cryptlen)
} //小於4k,就直接寫
//加密
ret = desenc(plain,plainlen,cryptbuf,&cryptlen);
if (ret != 0)
plainlen2 = fwrite(cryptbuf, 1, cryptlen, fp2);
if (plainlen2 != cryptlen)
end:
if (fp1 != null)
if (fp2 != null)
return 0;
}//解密
int filesymdec(const char *pfile1, const char *pfile2);
int cryptlen = 0;
fp1 = fopen(pfile1, "rb");
if (fp1 == null)
fp2 = fopen(pfile2, "wb");
if (fp2 == null)
//檔案開啟了,要拷貝資料了
while (!feof(fp1))
//解密==4k的資料
ret = desdec_raw(cryptbuf, cryptlen, plain, &plainlen);
if (ret != 0)
plainlen2 = fwrite(plain, 1, plainlen, fp2);
if (plainlen != cryptlen)
} //小於4k,就直接寫
//加密
ret = desdec(cryptbuf, cryptlen, plain, &plainlen);
if (ret != 0)
plainlen2 = fwrite(plain, 1, plainlen, fp2);
if (plainlen2 != plainlen)
end:
if (fp1 != null)
if (fp2 != null)
return 0;
}void main()
return;
}
檔案加解密
建立debuglzq 密碼 加密物件 private static symmetricalgorithm createrijndael string password,byte salt 加密檔案隨機數生成 private static randomnumbergenerator rand new ...
加密解密 替換加解密
加密解密 替換加解密 按一定規則重新替換明文的字元生成密文。可以有多種替換方式。include void encrypt char strdata,int ncode printf original s n strdata p strdata for i 0 i nlen i printf enco...
C 檔案簡單加解密
include include includevoid encfile char in filename,char pwd,char out filename 對檔案進行加密的具體函式 void decryptfile char in filename,char pwd,char out filen...