I want do an AES CBC decryption in Python without padding but I keep getting an error.
from Crypto.Cipher import AES BS = 16 pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS) unpad = lambda s : s[0:-ord(s[-1])] class AESCipher: def __init__( self, key ): self.key = key def encrypt( self, raw ): raw = pad(raw) iv = raw[:16] raw=raw[16:] #iv = Random.new().read( AES.block_size ) cipher = AES.new( self.key, AES.MODE_CBC, iv ) return ( iv + cipher.encrypt( raw ) ).encode("hex") def decrypt( self, enc ): iv = enc[:16] enc= enc[16:] cipher = AES.new(self.key, AES.MODE_CBC, iv ) return unpad(cipher.decrypt( enc)) mode = AES.MODE_CBC key = "blahahahblah ciphertext = blahblahblah key=key[:32] decryptor = AESCipher(key) decryptor.__init__(key) plaintext = decryptor.decrypt(ciphertext) print plaintext
Would I have to decode tbe hex value before decryption?
126 Bit
.....
above and beyond my question to unforeseen extents thanks so much mate phuarkin hell
thanks so much
YOU'RE WELCOME DUDE.
Join our real-time social learning platform and learn together with your friends!