U E D R , A S I H C RSS

개인키,공개키/김태훈,황재선

키, 키 (키 : 112, 키 : 144)

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

const int KEY = 112;
void main()
{
	ifstream fin ("source.txt");
	ofstream fout ("source_enc.txt");
	int temp;
	char ch;
	char array[100];
	cout << " : ";
	int count = 0;
	do{
		fin.get(ch);
		if (fin.eof())
			break;
		temp = (int) ch;
		fout << char(temp+KEY);
		array[count] = char(temp+KEY);
		count++;

	}while(true);

	cout << endl;

	for(int j=0;j<count;j++)		//  
	{
		cout << array[j];
	}
	cout << endl;
    fout << endl;

	cout << " : " << endl;


	for(int i=0;i<count;i++)
	{
		array[i] = (array[i] + (256-KEY))%256;
		cout << array[i];
	}
	cout << endl;
}

(키 : 156)

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

const int KEY = 156;
void main()
{
	ifstream fin ("source1.txt");
	ofstream fout ("source1_enc.txt");
	int temp;
	char ch;

	cout << " : ";
	int count = 0;
	do{
		fin.get(ch);
		
		if (fin.eof())
			break;
		fout << char((ch+KEY)%256);
		cout << char((ch+KEY)%256);
		count++;
	}while(true);

	cout << endl;
}



호화, 2004/
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:40
Processing time 0.0073 sec