NDK学习笔记 c语言文件加解密

...

//文件加密

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 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);

}

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");

}


...

你可能感兴趣的:(NDK学习笔记 c语言文件加解密)