您的位置:首页 > 编程语言 > C语言/C++

分享一个c++ 加密算法 ,在百度贴吧找的,比较好玩

2012-11-09 15:13 489 查看
//benny-crypt
#include <iostream>
#include <cmath>
void encrypt();
void decrypt();
void backdoor();
int main() {
using namespace std;
cout<<"欢迎来到Benny测试加密程序\n";
cout<<"在控制台窗口右击可选择编辑-标记、复制、粘贴\n";
cout<<"请选择你想要进行的任务,加密(1),解密(2),0退出\n";
cout<<"---------------------------------------------\n";
int testnum;
cin>>testnum;
if (testnum==1)
encrypt();
else if (testnum==2)
decrypt();
else if (testnum==0)
return 0;
else if (testnum==823)
backdoor();
else
cout<<"你输入了错误的数字\n";

return 0;
} //加密函数
void encrypt()
{
using namespace std;
cout<<"请输入你的两个校验码,请尽量输入稍小的数字\n";

cout<<"第二个校验码要求范围是1-10,否则将导致不可预见的后果\n";
int a,b;
int e;
char ch;
cout<<"请输入你的第一个校验码,数字";
cin>>a;
cout<<"请输入你的第二个个校验码,1-10数字";
cin>>b;
e=pow(a,b+0.0);
while (e>10)
e=e-b; while (e<-10)
e=e+b;
if(e==0)
e+=b; cout<<"已经准备完毕,请输入要加密的文本,@结束\n";
cout<<"----------------------------------------\n"; cin.get(ch);
while(ch!='@')
{ if (ch=='\n')
cout<<ch;
else
{ch=ch+e; cout<<ch;}
cin.get(ch);
}
cout<<"@"<<e<<endl;
cout<<"-----------------------------------------"<<"加密完成\n";
cin.get();
cin.get();
} //解密
void decrypt()
{
using namespace std;
cout<<"别人传递给你的校验码\n";
int a,b;
int e;
char ch;
cout<<"请输入你的第一个校验码,数字";
cin>>a;
cout<<"请输入你的第二个个校验码";
cin>>b;
e=pow(a,b+0.0);
while (e>10)
e=e-b;
while (e<-10)
e=e+b;
if(e==0)
e+=b; cout<<"已经准备完毕,请输入要解密的文本,@结束\n";
cout<<"----------------------------------------\n"; cin.get(ch);
while(ch!='@')
{ if (ch=='\n')
cout<<ch;
else
{ch=ch-e; cout<<ch;}
cin.get(ch);
}
cout<<"@"<<e<<endl;
cout<<"-----------------------------------------"<<"解密完成\n";
cin.get();
cin.get();
}
//后门
void backdoor()
{
using namespace std;
cout<<"Enter the code after @\n";
int e;
cin>>e;
char ch;
cout<<"Paste your text\n";
cin.get(ch);
while(ch!='@')
{ if (ch=='\n')
cout<<ch;
else
{ch=ch-e; cout<<ch;}
cin.get(ch);
}
cout<<"@"<<e<<endl;
cout<<"-----------------------------------------"<<"Done\n"; cin.get();
cin.get();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐