A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

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
  1. dehelloo
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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

  2. dehelloo
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Would I have to decode tbe hex value before decryption?

  3. dehelloo
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    126 Bit

  4. ChantySquirrel1129**
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    .....

  5. dehelloo
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    above and beyond my question to unforeseen extents thanks so much mate phuarkin hell

  6. dehelloo
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thanks so much

  7. ChantySquirrel1129**
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    YOU'RE WELCOME DUDE.

  8. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.