-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencrypt.c
44 lines (31 loc) · 885 Bytes
/
encrypt.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<stdio.h>
#include<string.h>
void encryptFile(FILE *inputFile, FILE *outputFile);
int main(){
FILE *inputFile, *outputFile;
inputFile = fopen("filename.txt", "r");
if (inputFile == NULL)
{
printf("File does not exist");
return 1;
}
outputFile = fopen("filename.txt-encrypted", "w");
if (outputFile == NULL)
{
printf("File does not exist");
return 1;
}
encryptFile(inputFile, outputFile);
printf("Encryption Successfull");
fclose(inputFile);
fclose(outputFile);
return 0;
}
void encryptFile(FILE *inputFile, FILE *outputFile){
char ch;
while ((ch = fgetc(inputFile)) != EOF)
{
char encryptedChar = '*';
fputc(encryptedChar, outputFile);
}
}