U E D R , A S I H C RSS

개인키,공개키/김회영,권정욱

개인키,공개키/김회영,권정욱


~cpp 
#include <iostream>  
#include <fstream>  
using namespace std;  
const int key = 50;
const int askii = 256;

int main(){  
	char secret[30];  
	cout << "암호화할 텍스트를 입력하세요 : ";  
	cin >> secret;  
	ifstream fin(secret);  
	ofstream fout("source_enc.txt");  
	
	char ch; 
	char text; 
	
	fin.get(text);  
	
	cout << "암호화를 실행합니다.\n";  
	
	while (!fin.eof()){ 
		ch = text + key; 
		if (int(ch)> 255) ch = ch % askii;
		if (text == '\n') {    
			cout << endl;  
			fout << endl;  
		}  
		else{  
			cout << ch; 
			fout << ch; 
		}  
		fin.get(text); 
	}  
	cout << endl;  
	fout << endl;  
	
	fin.close(); 
	fout.close(); 
	
	
	char unsecret[30]; 
	int key2;
	
	cout << "복호화할 텍스트를 입력하세요 공개키를 입력하세요 : "; 
	cin >> unsecret >> key2;
	ifstream ffin(unsecret); 
	ofstream ffout("resource_enc.txt"); 
	
	ffin.get(text);  
	
	cout << "복호화를 실행합니다.\n";  
	
	while (!ffin.eof()){ 
		ch = (text + key2) % askii; 
		if (text == '\n') {    
			cout << endl;  
			ffout << endl;  
		}  
		else{  
			cout << ch; 
			ffout << ch; 
		}  
		ffin.get(text); 
	}  
	
	return 0; 
} 
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:42
Processing time 0.0101 sec