Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

비밀키/김태훈

From ZeroWiki
Revision as of 05:29, 7 February 2021 by imported>Unknown
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

암호화

#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()));
}

복호화

#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()));
}