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.0109 sec