<spanstyle= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" >//fileencrydecry.cpp: Defines the entry point for a console application. * * use different or budget to encrypt files is mainly to read the characters in the file to the key for each character XOR or operation saved to another file to achieve the function of encryption because of the nature of the encryption and decryption can use the same function/#include "stdafx.h" #include <filesystem> #include <stdlib.h> #defineOK0 #defineERR-1 #defineKEY0xa9 intfileconvert (charszoldfile[], Charsznewfile[]) {file*poldfile=null; The file*pnewfile=null;//pointer is initialized to a NULL charctemp; if (szoldfile==null| | sznewfile==null) {Returnerr} poldfile=fopen (Szoldfile, "RB");//binary read-write file if (poldfile==null) {returnerr;} pnewfile= fopen (Sznewfile, "WB"); if (pnewfile==null) {fclose (poldfile); Returnerr}//must read the character first and then do the file end to Judge Ctemp=fgetc (Poldfile); while (!feof (poldfile))//encountered file end return value of 0 {putchar (ctemp); FPUTC (ctemp,pnewfile); Ctemp=fgetc (Poldfile) ^key;//XOR encryption file} Fclose (Poldfile); Fclose (Pnewfile)//////////////////File Returnok } int_tmain (intargc,_tchar*argv[]) {charszfile1[]= "1.txt"; charszfile2[]= "2.txt"; charszfile3[]= "3.txt";// Different file formats can be modified Fileconvert (SZFILE1,SZFILE2); System ("PauSe "); Return0; } </span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service