-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDEKEY.H
54 lines (34 loc) · 1.01 KB
/
DEKEY.H
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
45
46
47
48
49
50
51
52
53
54
#ifndef DEKEY_H // To make sure you don't declare the function more than once by including the header multiple times.
#define DEKEY_H
#include<iostream>
#include<fstream>
#include<cctype>
using namespace std;
void DeKey(char file1[20],char file2[20])
{
ifstream infile;
ofstream outfile;
char d[100];
cout<<"\nEnter the keyword\n";
cin >> d;
infile.open (file1); //opens the file to be encrypted
outfile.open (file2); //opens the output file
char c;
while (!infile.eof()) { //while not the end of the file
infile >> c;
for(int j = 0; d[j] != '\0'; j++) {
if ( (c - 3) == d[j]) {
c -= 3;
break;
}
}
if(c < 'a'){
c += 26;
}
outfile << c;
}
outfile << "\n\n"; //aesthetic purposes
infile.close(); //closes the original file
outfile.close(); //closes the file encryption
}
#endif