ndk学习笔记C语言文件加解密

来源:互联网 发布:熊族软件下载 编辑:程序博客网 时间:2024/06/07 10:08

       //文件加密

void encode(char normal_path [],char encode_path []){FILE * normal_fp = fopen(normal_path, "r");FILE * encode_fp = fopen(encode_path, "w");int ch;while ((ch = fgetc(normal_fp))!=EOF){fputc(ch ^ 7, encode_fp);}fclose(normal_fp);fclose(encode_fp);}


   //测试

void main() {char * normal_path = "F:\\open.txt";char * encode_path = "F:\\openone.txt";char * decode_path = "F:\\opendecode.txt";//encode(normal_path, encode_path);decode(encode_path, decode_path);system("pause");}


//解密

void decode(char encode_path[], char decode_path[]) {FILE * normal_fp = fopen(encode_path, "r");FILE * encode_fp = fopen(decode_path, "w");int ch;while ((ch = fgetc(normal_fp)) != EOF){fputc(ch ^ 7, encode_fp);}fclose(normal_fp);fclose(encode_fp);}


原创粉丝点击