?? edcode2.cpp
字號(hào):
#include "EDcode2.h"
void main()
{
int result;
int select;
char file[80];
char enfile[80];
char user_prikey[500];
char user_pubkey[500];
char server_prikey[500];
char server_pubkey[500];
EDcoder *mycoder0=new EDcoder();
EDcoder *mycoder1=new EDcoder();
EDcoder *mycoder2=new EDcoder();
cout<<"選擇一項(xiàng):(1~3)"<<endl;
cout<<"1,生成用戶RSA密鑰對(duì)"<<endl;
cout<<"2,加密"<<endl;
cout<<"3,解密"<<endl;
cout<<"您的選擇: ";
cin>>select;
switch(select)
{
case 1:
cout<<"輸入用戶私鑰文件名(我的是203117.pri.key)"<<endl;
cin>>user_prikey;
cout<<"輸入用戶公鑰文件名(我的是203117.pub.key)"<<endl;
cin>>user_pubkey;
mycoder0->Gen_rsa(user_prikey,user_pubkey);
break;
case 2:
cout<<"輸入用戶私鑰文件名(我的是203117.pri.key)"<<endl;
cin>>user_prikey;
mycoder1->Open_user_prikey(user_prikey);
cout<<"輸入服務(wù)器公鑰文件名"<<endl;
cin>>server_pubkey;
mycoder1->Open_server_pubkey(server_pubkey);
cout<<"輸入要加密的文件名"<<endl;
cin>>file;
cout<<"輸入加密后的文件名"<<endl;
cin>>enfile;
result=mycoder1->Encrypt(file,enfile);
if(result!=0)
cout<<"error encrypting:(code)"<<result<<endl;
else
cout<<"succeed in encrypting!\n"<<endl;
break;
case 3:
cout<<"輸入用戶公鑰文件名(我的是203117.pub.key)"<<endl;
cin>>user_pubkey;
mycoder2->Open_user_pubkey(user_pubkey);
cout<<"輸入服務(wù)器私鑰文件名(要是文件用老師的公鑰加密,那私鑰請(qǐng)老師提供,謝謝)"<<endl;
cin>>server_prikey;
mycoder2->Open_server_prikey(server_prikey);
cout<<"輸入加了密的文件名"<<endl;
cin>>enfile;
cout<<"輸入解密后的文件名"<<endl;
cin>>file;
result=mycoder2->Decrypt(enfile,file);
if(result!=0)
cout<<"error encrypting:(code)"<<result<<endl;
else
cout<<"succeed in decrypting!\n"<<endl;
break;
}
delete mycoder0;
delete mycoder1;
delete mycoder2;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -