加密解密

来源:百度知道 编辑:UC知道 时间:2024/05/15 11:51:46
维吉尼亚

/*维吉尼亚密码(Vigenère Cipher)
加密程序v1.0
0 error(s), 0 warning(s)
Dolphin*/
#include<iostream>
#include<string>
using namespace std;
#include<conio.h>

char Toupper(char ch)
{//把小写字母转换成大写字母
if(ch >= 'A' && ch <= 'Z')
return ch;
else if(ch >= 'a' && ch <= 'z')
return ch - 'a' + 'A';
else return 0;
}

int AlphaToNum(char ch)
{//把字母转换成对应的数字
return Toupper(ch) - 'A';
}

char NumToAlpha(int num)
{//把数字转换成对应的字母
return num + 'A';
}
void main()
{
string strPlaintext;
string strCiphertext;
string strTemp;
string strKey;
string strKeyStream;
cout<<"明文:"<<endl;
cin>>strPlaintext;
strCiphertext = strTemp = strPlaintext;
for(string::iterator si = strTemp.begin();si != strTemp.