U E D R , A S I H C RSS

비밀키/최원서

암호화

~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;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:37
Processing time 0.0100 sec