巴蒂斯塔135246代表密码
密文:1、3、5,2、4、6(两层加密)
第一层对照文章找出相应的字,这两个字的拼音就是密文。
具体的步骤就是135为一组、246为一组,每组的三个数分别对应上述文章中的第几条第几点的内容的第几个字。
第二层将得到的密文就行维吉尼亚解密,密钥是文章中反反复复出现过的一个词的拼音,即文物。
最后将维吉尼亚翻译出来的英文对应英文字母的顺序,可以得到六位数的密码。
给,网上的C++的基本都有问题,我给你改好一个,已经编译运行确认,
#includeiostream
using namespace std;
#define MINCHAR 32
#define CHARSUM 94
char table[CHARSUM][CHARSUM];
bool Init();
bool Encode(char* key, char* source, char* dest);
bool Dncode(char* key, char* source, char* dest);
int main()
{
if(!Init())
{
cout "初始化错误!" endl;
return 1;
}
char key[256];
char str1[256];
char str2[256];
int operation;
while(1)
{
do
{
cout "请选择一个操作:1. 加密; 2. 解密; -1. 退出\n";
cin operation;
}while(operation != -1 operation != 1 operation != 2);
if(operation == -1)
return 0;
else if(operation == 1)//加密
{
cout "请输入密钥:";
cin key;
cout "请输入待加密字符串:";
cin str1;
Encode(key, str1, str2);
cout "加密后的字符串:" str2 endl;
}
else if(operation == 2)//解密
{
cout "请输入密钥:";
cin key;
cout "请输入待解密字符串:";
cin str1;
Dncode(key, str1, str2);
cout "解密后的字符串:" str2 endl;
}
cout endl;
}
return 0;
}
// 初始化维吉尼亚方阵
bool Init()
{
int i, j;
for(i = 0; i CHARSUM; i++)
{
for(j = 0; j CHARSUM; j++)
{
table[i][j] = MINCHAR + (i + j) % CHARSUM;
}
}
return true;
}
// 加密
// key:密钥
// source:待加密的字符串
// dest:经过加密后的字符串
bool Encode(char* key, char* source, char* dest)
{
char* tempSource = source;
char* tempKey = key;
char* tempDest = dest;
do
{
*tempDest = table[(*tempKey) - MINCHAR][(*tempSource) - MINCHAR];
tempDest++;
if(!(*(++tempKey)))
tempKey = key;
}while(*tempSource++);
dest[strlen(source)] = 0;
return true;
}
// 解密
// key:密钥
// source:待解密的字符串
// dest:经过解密后的字符串
bool Dncode(char* key, char* source, char* dest)
{
char* tempSource = source;
char* tempKey = key;
char* tempDest = dest;
char offset;
do
{
offset = (*tempSource) - (*tempKey);
offset = offset = 0 ? offset : offset + CHARSUM;
*tempDest = MINCHAR + offset;
tempDest++;
if(!(*(++tempKey)))
tempKey = key;
}while(*++tempSource);
dest[strlen(source)] = 0;
return true;
}
你所说的“这个维吉尼亚密码”指的是哪个维吉尼亚密码?
好吧,我知道了,是百度百科的(答你这题还得有点联想能力……)
“TO BE OR NOT TO BE THAT IS THE QUESTION
当选定RELATIONS作为密钥时,加密过程是:明文一个字母为T,第一个密钥字母为R”
额,上面不是说了吗用"RELATIONS"作为密钥那么明文第一个字母T对应的密钥就是R。你要想问"RELATIONS"这个密钥砸来的?我告诉你,想来的,这个密钥你想用啥单词就用啥单词,越生僻的单词越好,选完密钥后加密,但密钥长度不够,那么就重复使用,如下:
密钥:RELAT IONSR ELATI ONSRE LATIO NSREL
明文:TOBEO RNOTT OBETH ATIST HEQUE STION
密文:KSMEH ZBBLK SMEMP OGAJX SEJCS FLZSY
给你个维吉尼亚密码加密解密用的程序,使用后就能更好理解:
(别告诉我这是个只上一次的小号……我的采纳率被这种号害惨了……)