More actions
imported>Unknown No edit summary |
(Repair batch-0004 pages from live compare) |
||
| Line 11: | Line 11: | ||
int temp; | int temp; | ||
char ch; | char ch; | ||
char array | char array[100]; | ||
cout << "암호값 : "; | cout << "암호값 : "; | ||
int count = 0; | int count = 0; | ||
| Line 20: | Line 20: | ||
temp = (int) ch; | temp = (int) ch; | ||
fout << char(temp+KEY); | fout << char(temp+KEY); | ||
array | array[count] = char(temp+KEY); | ||
count++; | count++; | ||
| Line 29: | Line 29: | ||
for(int j=0;j<count;j++) // 암호값 출력 | for(int j=0;j<count;j++) // 암호값 출력 | ||
{ | { | ||
cout << array | cout << array[j]; | ||
} | } | ||
cout << endl; | cout << endl; | ||
| Line 39: | Line 39: | ||
for(int i=0;i<count;i++) | for(int i=0;i<count;i++) | ||
{ | { | ||
array | array[i] = (array[i] + (256-KEY))%256; | ||
cout << array | cout << array[i]; | ||
} | } | ||
cout << endl; | cout << endl; | ||
| Line 75: | Line 75: | ||
---- | ---- | ||
[[암호화실습]], | [[암호화실습]], 데블스캠프2004/목요일 | ||
Latest revision as of 00:37, 27 March 2026
개인키, 공개키 (개인키 : 112, 공개키 : 144)
#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;
}
원본 알아내기 (공개키 : 156)
#include <fstream>
#include <iostream>
using namespace std;
const int KEY = 156;
void main()
{
ifstream fin ("source1.txt");
ofstream fout ("source1_enc.txt");
int temp;
char ch;
cout << "원본값 : ";
int count = 0;
do{
fin.get(ch);
if (fin.eof())
break;
fout << char((ch+KEY)%256);
cout << char((ch+KEY)%256);
count++;
}while(true);
cout << endl;
}
암호화실습, 데블스캠프2004/목요일