下载题目后无法打开 需要添加.zip的后缀才能打开
题目:
公元前一百年,在罗马出生了一位对世界影响巨大的人物,他生前是罗马三巨头之一。他率先使用了一种简单的加密函,因此这种加密方法以他的名字命名。
以下密文被解开后可以获得一个有意义的单词:FRPHEVGL
你可以用这个相同的加密向量加密附件中的密文,作为答案进行提交。
密文:
ComeChina
不知道凯撒密码的偏移量,可以尝试使用暴力破解方法,也就是尝试所有可能的偏移量,逐个进行解密,然后手动判断哪一个解密结果是可读的文本。以下是一个使用C++编写的凯撒解码代码,通过暴力穷举所有偏移量进行解码:
#include <iostream>
#include <string>
using namespace std;
// 凯撒解密函数
string caesarDecrypt(string encryptedText, int shift) {
string decryptedText = "";
int length = encryptedText.length();
// 对每个字符进行解密操作
for (int i = 0; i < length; ++i) {
// 解密大写字母
if (isupper(encryptedText[i])) {
char decryptedChar = (encryptedText[i] - shift - 65 + 26) % 26 + 65;
decryptedText += decryptedChar;
}
// 解密小写字母
else if (islower(encryptedText[i])) {
char decryptedChar = (encryptedText[i] - shift - 97 + 26) % 26 + 97;
decryptedText += decryptedChar;
}
// 其他字符保持不变
else {
decryptedText += encryptedText[i];
}
}
return decryptedText;
}
// 凯撒暴力破解函数
void caesarBruteForce(string encryptedText) {
cout << "开始暴力破解..." << endl;
// 尝试所有可能的偏移量
for (int shift = 1; shift <= 25; ++shift) {
cout << "偏移量: " << shift << endl;
cout << "解密结果: " << caesarDecrypt(encryptedText, shift) << endl;
cout << "-------------------" << endl;
}
cout << "暴力破解完成!" << endl;
}
int main() {
string encryptedText;
// 输入要解密的文本
cout << "请输入要解密的文本:";
getline(cin, encryptedText);
// 调用凯撒暴力破解函数进行解密
caesarBruteForce(encryptedText);
return 0;
}
可以得出偏移量为13
对密文加密可得出结果flag{PbzrPuvan}