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


    //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();
    }

  • 相关阅读:
    MySQL 删除有外键约束的表数据
    Python 类装饰器解析
    保持SSH连接的linux服务器不断线
    数字货币交易所常用概念
    Python f-string
    Linux sed命令
    CAS机制详解
    MySQL缓存机制
    PHP网络请求优化
    Java三大特性---继承
  • 原文地址:https://www.cnblogs.com/gisbeginner/p/2762687.html
Copyright © 2020-2023  润新知