int p;
printf("Cfare veprimi deshiron te besh..? :\n");
printf("Encryption = 1\nDecryption = 2\n");
cin >> p;
switch (p) {
case 1:
FILE *fdr,*fdw;
char ch,fileName[20],output[20];
int op;
printf("Vendos emrin e File qe deshiron te besh Encrypt:\n");
scanf("%s",fileName);
printf("Ne cfare emri deshironi ta ruani filein e ri? \n:");
scanf("%s",output);
fdr=fopen(fileName,"r");
fdw=fopen(output,"w");
if(fdr==NULL){
printf("\nFile nuk ekziston...!\n");
exit(0);
}
ch=fgetc(fdr);
while(ch!=EOF){
op=(int)ch;
op=op+5;
fprintf(fdw,"%c",op);
ch=fgetc(fdr);
}
fclose(fdw);
fclose(fdr);
printf("File-i eshte encriptuar me sukses...\n",output);
return 0;
break;
case 2:
FILE *fdrr,*fdww;
char chh,fileNamee[20],outputt[20];
int opp;
printf("Vendos emrin e File qe deshiron te besh Decrypt:\n");
scanf("%s",fileNamee);
printf("Ne cfare emri deshironi ta ruani filein e ri?:\n");
scanf("%s",outputt);
this will encrypt and decrypt the file and its more secure than you might think (its breakable, but it takes a lot of work). Its fine for casual data encryption to deter nosey people :)
int password;
cin >> password;
srand(password);
for(all the bytes)
{
byte ^= rand()%256;
write byte to encrypted file
}
If they give the wrong password, it just gives garbage output.