It's very easy to understand this method to encrypt the target file. we can use the ~ or ^ to make such file encrypted.
If we continue the such action, we can get the decryption file.
here is my code to make such method come true.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
FILE *name;
FILE *temp;
char nameFile[30];
char tempFile[100];
while(1){
printf("input filename:\n");
scanf("%s",nameFile);
if( (name=fopen(nameFile,"rb+"))==NULL){
printf("fail to open the original file.");
return -1;
}
if( (temp=fopen("Temp.txt","wb+"))==NULL ){
printf("fail to write the content to temp file.");
return -1;
}
while(!feof(name)){ //if returned value exist ? 0 : !0 the key process
char ch=fgetc(name);
if((int)ch!=-1&&(int)ch!=0){
ch=~ch;
fputc(ch,temp);
}
}
fclose(name);
fclose(temp);
sprintf(tempFile,"del %s",nameFile);
system(tempFile); // we use the bat command to process delete and rename target file.
sprintf(tempFile,"ren Temp.txt %s",nameFile);
system(tempFile);
}
return 0;
}