U E D R , A S I H C RSS

비밀키/나휘동

비밀키를 입력받아서 파일에 있는 내용을 암호화 하는 프로그램

~cpp 
#include <iostream>  
#include <fstream>  
using namespace std;  
  
void main()  
{  
        char filename[10];  
        cout << "파일 이름 : ";  
        cin >> filename;  
        ifstream fin(filename);  
        ofstream fout("encode.txt");  
          
        char key;  
        cout << "비밀키 : ";  
        cin >> key;  
  
        cout << "처리중입니다..."<< endl;  
  
        char ch;  
        while( !fin.eof() ){  
                ch = fin.get();  
                ch += key;//암호화  
                fout << ch;  
                cout << ch;  
        }  
        cout << endl;  
        fin.close();  
        fout.close();  
}  

~cpp 
#include <iostream>  
#include <fstream>  
using namespace std;  
  
void main()  
{  
        char filename[10];  
        cout << "파일 이름 : ";  
        cin >> filename;  
        ifstream fin(filename);  
        ofstream fout("decode.txt");  
          
        char key;  
        cout << "비밀키 : ";  
        cin >> key;  
  
        cout << "처리중입니다..."<< endl;  
  
        char ch;  
        while( !fin.eof() ){  
                ch = fin.get();  
                ch -= key;//복호화  
                fout << ch;  
                cout << ch;  
        }  
        cout << endl;  
        fin.close();  
        fout.close();  
}  

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:37
Processing time 0.0122 sec