在 pycrypto 中,解密明文前面的 b 是什么意思



我正在尝试使用PyCrypto中实现的DES算法加密纯文本。但是,当我打印加密文本,然后使用生成的加密文本对其进行解密时,似乎每次都会添加额外的 b。这是一个错误还是只是我无知的其他事情?

下面是代码示例:

des = DES.new('01234567', DES.MODE_ECB)
text = input('Enter plain text: ')
cipher_text = des.encrypt(text)
print('Cipher Text:' + str(cipher_text))
decipher_text = des.decrypt(ciphertext=cipher_text)
print('Deciphered text is: ' + str(decipher_text))

以及由此产生的输出:

Enter plain text: abcdefgh
Cipher Text:b'xecxc2x9exd9] axd0'
Deciphered text is: b'abcdefgh'

b 指控这是一个二进制字符串。

最新更新