int
encryption(char
*in_fname, char
*pwd, char
*out_fname){ FILE
*fp_1, *fp_2; register
char
ch; int
i = 0, pwd_length = 0; fp_1
= fopen(in_fname,
"rb"); if
(fp_1 == NULL) { fprintf(stderr,
"cannot
open in-file: %s.\n",
in_fname); return
-1; } fp_2
= fopen(out_fname,
"wb"); if
(fp_2 == NULL) { fprintf(stderr,
"cannot
open out-file: %s.\n",
out_fname); return
-1; } pwd_length
= strlen(pwd); while
( (ch = fgetc(fp_1))
!= EOF) fputc(ch
^ pwd[i > pwd_length ? i = 0 : i++], fp_2); fclose(fp_1); fclose(fp_2); return
0;}
网上找的文件加密程序,还是没看懂
本文介绍了一种基于文件逐字节与密码异或方式的简单加密方法,通过该方法可以对文件进行加密并使用相同的步骤进行解密。这种方法在确保数据安全性的同时,提供了简便的操作流程。
871

被折叠的 条评论
为什么被折叠?



