~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;
}