암호화

~cpp 
#include <fstream> 
#include <iostream>
#include <stdlib.h>
using namespace std; 
 
int main() 
{ 
	ifstream fin("input.txt"); // fin과 input.txt를 연결  
    ofstream fout("output.txt"); // fout과 output.txt를 연결 
	cout << "숫자 입력> ";
	int f;
	cin >> f;
	char a[20];
	for (int i = 0; ; i++)
	{
		fin.getline(a,20);
		if (fin.eof())
			break;

		int c = strlen(a);
		for (int d=0;d<c;d++)
		{
			cout << (char)(a[d]+f);
			fout << (char)(a[d]+f);
		}
		cout << endl;
		fout << endl;
	}
	cout << endl;
    return 0;
}


복호화

~cpp 
#include <fstream>
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
	ifstream fin("output.txt"); // fin과 input.txt를 연결  
    ofstream fout("output2.txt"); // fout과 output.txt를 연결 
	cout << "숫자 입력> ";
	int f;
	cin >> f;
	char a[20];
	for (int i = 0; ; i++)
	{
		fin.getline(a,20);
		if (fin.eof())
			break;
		int c = strlen(a);
		for (int d=0;d<c;d++)
		{
			cout << (char)(a[d]-f);
			fout << (char)(a[d]-f);
		}
		cout << endl;
		fout << endl;
	}
	cout << endl;
    return 0;
}
Retrieved from http://wiki.zeropage.org/wiki.php/비밀키/최원서
last modified 2021-02-07 05:29:37