I am making an AES encryption/decryption program using PyAES, and when I print an output, it looks like this:
b'\xb6\xd52#\xb1\xd5a~.L\xc2M\x83U\xb3\xf6'
(encrypted)
b'TextMustBe16Byte'
(plaintext)
I want to eliminate the b and the apostrophes so that it looks cleaner on the front end.
My code:
import pyaes
import os
# A 256 bit (32 byte) key
key = os.urandom(32)
# For some modes of operation we need a random initialization vector
# of 16 bytes
iv = os.urandom(16)
aes = pyaes.AESModeOfOperationCBC(key, iv = iv)
plaintext = "TextMustBe16Byte"
ciphertext = aes.encrypt(plaintext)
# '\xd6:\x18\xe6\xb1\xb3\xc3\xdc\x87\xdf\xa7|\x08{k\xb6'
print(ciphertext)
# The cipher-block chaining mode of operation maintains state, so
# decryption requires a new instance be created
aes = pyaes.AESModeOfOperationCBC(key, iv = iv)
decrypted = aes.decrypt(ciphertext)
print(decrypted)