Hack Forums
[C] Open File, Encrypt and then save to a new file - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C] Open File, Encrypt and then save to a new file (/showthread.php?tid=5945401)



Open File, Encrypt and then save to a new file - Voxi - Feb 26, 2019

Hi guys, how would I open a file, encrypt it with XOR and then save it?
https://gyazo.com/ff5ef33688256f51826d909cdb932b2e
I've managed to get it working with user input but the file is only saving what the user is typing in.

I want the user to only be able to select what encryption type they want as I plan to add 2 more.


RE: Open File, Encrypt and then save to a new file - morph - Feb 27, 2019

I wouldn't recommend using XOR to "encrypt" data.


RE: Open File, Encrypt and then save to a new file - Auriana - Feb 27, 2019

Code
fin = fopen("filename","rb");
fread(buffer,sizeof(char),sizeof(buffer),fin);
fclose(fin);
setXORMessage(buffer,key);
fout = fopen("enc","wb");
fwrite(buffer,sizeof(buffer),sizeof(char),fout);
fclose(fout);



RE: Open File, Encrypt and then save to a new file - Voxi - Feb 27, 2019

(Feb 27, 2019 08:53 AM)Morph Wrote:  I wouldn't recommend using XOR to "encrypt" data.
It is for an assignment :)