-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathencryption.cpp
More file actions
49 lines (49 loc) · 1.04 KB
/
encryption.cpp
File metadata and controls
49 lines (49 loc) · 1.04 KB
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
#include<iostream>
#include<fstream>
#include<stdio.h>
using namespace std;
int main()
{
char fileName[30], ch;
fstream fps, fpt;
cout<<"Enter the Name of File: ";
gets(fileName);
fps.open(fileName, fstream::in);
if(!fps)
{
cout<<"\nError Occurred, Opening the Source File (to Read)!";
return 0;
}
fpt.open("tmp.txt", fstream::out);
if(!fpt)
{
cout<<"\nError Occurred, Opening/Creating the tmp File!";
return 0;
}
while(fps>>noskipws>>ch)
{
ch = ch+100;
fpt<<ch;
}
fps.close();
fpt.close();
fps.open(fileName, fstream::out);
if(!fps)
{
cout<<"\nError Occurred, Opening the Source File (to write)!";
return 0;
}
fpt.open("tmp.txt", fstream::in);
if(!fpt)
{
cout<<"\nError Occurred, Opening the tmp File!";
return 0;
}
while(fpt>>noskipws>>ch)
fps<<ch;
fps.close();
fpt.close();
cout<<"\nFile '"<<fileName<<"' Encrypted Successfully!";
cout<<endl;
return 0;
}