Encryption Casear密码暴力攻击-所有可能的密钥
我需要代码方面的帮助。我必须找出凯瑟密码中所有可能的钥匙。我的信息中有上下两个字母,没有其他字母。但我的密钥在代码中重复,但我需要每个密钥都是唯一的。请帮忙Encryption Casear密码暴力攻击-所有可能的密钥,encryption,Encryption,我需要代码方面的帮助。我必须找出凯瑟密码中所有可能的钥匙。我的信息中有上下两个字母,没有其他字母。但我的密钥在代码中重复,但我需要每个密钥都是唯一的。请帮忙 #include <stdio.h> #include <string.h> #include <ctype.h> char cryptedText[]; //here could be any crypted text int main() { for (int key =
#include <stdio.h>
#include <string.h>
#include <ctype.h>
char cryptedText[]; //here could be any crypted text
int main()
{
for (int key = 0; key <= 52; ++key)
{
for (int i = 0; i < strlen(cryptedText); ++i)
{
if (cryptedText[i] >= 'A' && cryptedText[i] <= 'Z')
{
printf("%c", ((cryptedText[i] - 'A' + key)%26 + 'A'));
}
else
{
printf("%c", ((cryptedText[i] - 'a' + key)%26 + 'a'));
}
}
printf("Number of key %d\n", key);
}
return 0;
}
#包括
#包括
#包括
字符加密文本[]//这里可能有任何加密文本
int main()
{
对于(int key=0;key='A'&&cryptedText[i]您需要某种方法来跟踪您已经提取的密钥。可能将它们存储在一个集合中,该集合旨在仅存储唯一的值。然后您可以在最后打印出该集合中的所有值