U E D R , A S I H C RSS

비밀키/김태훈

암호화

~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()));
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:36
Processing time 0.0089 sec