c++ - 暴力异或密码

标签 c++ cryptography xor encryption cracking

是否可以暴力破解标准 XOR 密码?

知道这个:

*#(I@KI

用异或函数编码

//
std::string CStringCoding::Xor( const std::string& strIn )
{
    std::string sOut = "";

    for(std::size_t loop = 0; loop < strIn.size(); loop++)
    {
        unsigned int iCharacter = static_cast<unsigned int>(strIn[loop] ^ sKey[loop % sKey.size()]);
        sOut += iCharacter;
    }

    return sOut;
}

我可以使用经典的单词表方法来暴力破解吗?

我在想:

Generate a Wordlist KEY

XOR the *#(I@KI with a KEY to DECIPHER it and obtain a STRING

XOR the STRING with a KEY to CIPHER it

Compare newly CIPHERED STRING with the INPUT CIPHERED STRING

If they match, the KEY has been found

我没有测试它,只是在我采取行动和花太多时间做一些行不通的事情之前询问一下。

谢谢。

最佳答案

假设您正在加密有意义的人类可读文本,则有可能破解此 XOR cipher如果攻击者将拥有:

  1. 使用 key 重用编码的密文(例如循环 % sKey.size() )
  2. 2个用相同 key 编码的密文

Frequency analysis可以打破这两种情况。

但是用与消息长度相同的真正随 secret 钥对明文进行异或处理是可以的。这将是牢不可破的密码:One-Time Pad

OTP is immune even to brute-force attacks.Trying all keys simply yields all plaintexts, all equally likely to be the actual plaintext

关于c++ - 暴力异或密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17693514/

相关文章:

python - 无法使用 2 层多层感知器 (MLP) 学习 XOR 表示

swift - 成员 'CBC' 不带参数

ios - 在 Swift 中使用 CCCrypt (CommonCrypt) 的问题

c - 对一个非常大的文件进行 XOR

c++ - 关于Basic C++ Reserving Structs的查询

c# - 在 .NET 中使用 OpenSSL 加密和解密文件

JavaScript - 字符串按位异或?

c# - 如何以编程方式创建用户配置文件

c++ - 我认为下面的陈述不正确或者我遗漏了什么?

c++ - OpenCV不会打开许多​​相同格式的视频的一些视频