Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Encrypt Data Store in Text File
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- FILE *fp1, *fp2;
- char str[500];
- int i, ch;
- clrscr();
- //First Create a File. Path -> C:/TurboC4/TC/Bin/
- fp1=fopen("LIS.txt","r");
- if(fp1==NULL)
- {
- printf("\n Opened");
- exit(1);
- }
- ch=fgetc(fp1);
- for(i=0;(i<500)&&(feof(fp1)==0);i++)
- {
- str[i]=(char)ch;
- ch=fgetc(fp1);
- }
- str[i]='\0';
- printf("\n Actual Data : %s ", str);
- fclose(fp1);
- //Encrypted Data File Created
- fp2=fopen("Hello.txt","w");
- if(fp2==NULL)
- {
- printf("\n Opened");
- exit(1);
- }
- for(i=0;i<str[i];i++)
- {
- str[i]=str[i]-2;
- fputc(str[i],fp1);
- }
- printf("\n Encrypt Data : %s", str);
- fclose(fp2);
- getch();
- }
Add Comment
Please, Sign In to add comment