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

C/C++:移位密码穷举解密

2014-10-16 23:28 211 查看
#include<iostream>
using namespace std;

#define N 1000

void decrypt(char x
)
{
for(int i=1;i<=25;++i)
{
for(int j=0;;++j)
{
if(x[j]>96&&x[j]<123)
x[j]=(x[j]-1-122)%26+122;
else if(x[j]>64&&x[j]<91)
x[j]=(x[j]-1-90)%26+90;
else
x[j]=x[j];
if(x[j]==0) break;
}
cout<<"The result is:"<<x<<endl;
}
}

int main()
{
char x
= {0};

cout<<"Please enter the message:";
cin.getline(x,N);

decrypt(x);

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息