U E D R , A S I H C RSS

비밀키/황재선

비밀키

~cpp 
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
	ifstream fin("source.txt");
	ofstream fout("source_enc.txt");

	char input;
	int i;

	char data[100] = {'0', };
	
	int count = 0;
	cout << "원본값" << endl;
	while(true)
	{
		fin.get(input);		
		if (fin.eof())
			break;
		cout << input;
		data[count] = input;
		count++;
	}
	data[count] = NULL;
	cout << endl;


	int key;
	cout << "Key 입력 :  ";
	cin >> key;
	
	cout << "암호화" << endl;
	for (i = 0; data[i] != NULL ;i++)
	{
		data[i] += key;
		fout << char(data[i]);
		cout << char(data[i]);
	}
	cout << endl;
	fout << endl;
	cout << "복호화" << endl;
	for (i = 0; data[i] != NULL ;i++)
	{
		data[i] -= key;
		fout << char(data[i]);
		cout << char(data[i]);
	}
	cout << endl;

	return 0;
}

암호화실습, 블스캠프2004/목요일
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:37
Processing time 0.0086 sec