Search code examples
pythonpython-3.xencryptionencodingpycrypto

What does the b in front of the decrypted plaintext mean in pycrypto?


I'm trying to encrypt a plain text using DES algorithm implemented in PyCrypto. However, when I print the encrypted text and then decrypt it using the generated encrypted text an additional b seems to get added every time. Is this an error or just something else that I'm being ignorant about?

Here's the code sample:

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))

And the resultant output:

Enter plain text: abcdefgh
Cipher Text:b'\xec\xc2\x9e\xd9] a\xd0'
Deciphered text is: b'abcdefgh'

Solution

  • The b indictes this is a binary string.