U E D R , A S I H C RSS

개인키,공개키/박능규,조재화

개인키 = 100

~cpp 
//5
//5+2 = 7
//7+(10-2)= 15 = 5

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

int main()
{
	ifstream fin("source.txt");
	ofstream fout("output.txt");
	ofstream fout2("result.txt");

	char array[100];
	int count=0;
	for (int i=0 ; !fin.eof(); i++)
	{
		
		//fin >> array[i];
		array[i] = fin.get(); 
		count ++;
	}
	int key=100;

	//암호화  작업..
	for (i=0; i<count-1 ; i++)
	{
		array[i]+=key;
	}
	for (i=0; i<count-1 ; i++)
	{
		cout <<	array[i];
		fout <<	array[i];
	}
	cout << endl;

	
	//해석  1 -> 101 +156 ->257%256 ->1
	int open_key;
	cout<<"공개키 : ";
	cin >> open_key;
	for (i=0; i<count-1 ; i++)
	{
		
		array[i]+=open_key;	//(256-key == open_key)
		array[i]= array[i]%256;
				
	}
	for (i=0; i<count-1 ; i++)
	{
		cout <<	array[i];
		fout2 << array[i];
	}
	cout<<endl;
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.1008 sec