No older revisions available
No older revisions available
암호화 ¶
~cpp
#include <fstream>
#include <iostream>
using namespace std;
void main()
{
ifstream fin ("source.txt");
ofstream fout ("source_enc.txt");
int x;
cout << "KEY 값을 입력하세요 : "
cin >> x;
int temp;
char ch;
do{
fin.get(ch);
temp = (int) ch;
fout << char(temp-x);
}while(!(fin.eof()));
}
복호화 ¶
~cpp
#include <iostream>
#include <fstream>
using namespace std;
void main()
{
ifstream fin("source_enc.txt");
ofstream fout("normal.txt");
int y;
cout << "복호화 할 KEY 값을 입력하세요";
cin >> y;
int temp;
char ch;
do{
fin.get(ch);
temp = (int) ch;
fout << char(temp+y);
}while(!(fin.eof()));
}