A community for students.
Here's the question you clicked on:
 0 viewing
dehelloo
 one year ago
I want do an AES CBC decryption in Python without padding but I keep getting an error.
dehelloo
 one year ago
I want do an AES CBC decryption in Python without padding but I keep getting an error.

This Question is Open

dehelloo
 one year ago
Best ResponseYou've already chosen the best response.0from 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

dehelloo
 one year ago
Best ResponseYou've already chosen the best response.0Would I have to decode tbe hex value before decryption?

dehelloo
 one year ago
Best ResponseYou've already chosen the best response.0above and beyond my question to unforeseen extents thanks so much mate phuarkin hell

ChantySquirrel1129**
 one year ago
Best ResponseYou've already chosen the best response.1YOU'RE WELCOME DUDE.
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.