请问这个程序怎么编解密的?

来源:百度知道 编辑:UC知道 时间:2024/06/07 12:39:56
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
void main()
{
char s[100];
int o(0);
int u[100];
cout<<"请输入待加密字串:";
gets(s);
while(s[o]!='\0')o++;
cout<<"加密后的字符:";
for(int x=0;x<=o-1;x++)
{
u[x]=pow(pow(s[x],2)*3/4+1.2,3);
if(u[x]<0)
{
u[x]=-u[x];
}
cout<<u[x];
}
cout<<endl;
system("pause");
}

谢谢!

解密s[x]=sqrt(4*(pow(u[x],1.0/3.0)-1.2)/3)

为什么非要解密呢,
比如:你输入abc;
密文是:597951412 239410346 2050468051
上面的加密保证了:你每次输入abc,都得到相同的密文,这点很重要(并不是任何一个函数在输入值后,能得到一样的密文)
密文传送地:会有一张表,对应:
a:xxxx
b:xxxxx
c:xxxxx
d:xxxxx

你得到密文以后去查那张表就能得到明文

这种加密的弊端是:第三者知道了加密算法,也就知道了密文的内容