I encrypted a text in AES with the code below and decrypt the Ciphertext with Online decryption websites (Website 1, Website 2). But, the decrypted text from all websites contains some unwanted strings in front as shown in this picture.
import base64
import hashlib
from Crypto import Random
from Crypto.Cipher import AES
key = b'asdfghjklqwertyu'
class AESCipher(object):
def __init__(self, key):
self.bs = AES.block_size
self.key = key
def encrypt(self, raw):
raw = self._pad(raw)
iv = Random.new().read(AES.block_size)
cipher = AES.new(self.key, AES.MODE_CBC, iv)
return base64.b64encode(iv + cipher.encrypt(raw.encode()))
def _pad(self, s):
return s + (self.bs - len(s) % self.bs) * chr(self.bs - len(s) % self.bs)
a = AESCipher(key)
print(a.encrypt('Hey There!'))