Program to encrypt and decrypt
a file
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fptr;
char c;
clrscr();
printf("Enter the text to be stored in the file.\n");
printf("Use ^Z or F6 at the end of the text and press ENTER : \n\n");
fptr = fopen("ENCDEC.DAT","w");
while((c = getchar()) != EOF)
fputc(c, fptr);
fclose(fptr);
printf("\n\nData output in encrypted form : \n\n");
fptr = fopen("ENCDEC.DAT", "r");
while((c = fgetc(fptr)) != EOF)
printf("%c", c + 1);
fclose(fptr);
printf("\n\nData output in decrypted form : \n\n");
fptr = fopen("ENCDEC.DAT", "r");
while((c = fgetc(fptr)) != EOF)
printf("%c", c);
fclose(fptr);
getch();
}
Output:
Enter the text to be stored in the file.
Use ^Z or F6 at the end of the text and press ENTER :
Computer Practice - II
D.D. Publications
^Z
Data output in encrypted form :
Dpnqvufs!Qsbdujdf!.!JJ
E/E/!Qvcmjdbujpot
Data output in decrypted form :
Computer Practice - II
D.D. Publications
-
UpdatedDec 31, 2019
-
Views11,823
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order