From cb3c036fb47c6f88331a063013814cdbaca14e96 Mon Sep 17 00:00:00 2001 From: Bill Buchanan Date: Mon, 8 Feb 2021 18:49:34 +0000 Subject: [PATCH] Update possible_ans.md --- unit02_symmetric/lab/possible_ans.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/unit02_symmetric/lab/possible_ans.md b/unit02_symmetric/lab/possible_ans.md index 3ec23a6..9624da5 100644 --- a/unit02_symmetric/lab/possible_ans.md +++ b/unit02_symmetric/lab/possible_ans.md @@ -473,7 +473,7 @@ def decrypt(ciphertext,key, mode): encobj = AES.new(key,mode) return(encobj.decrypt(ciphertext)) -key = hashlib.sha256(password).digest() +key = hashlib.sha256(password.encode()).digest() ciphertext=binascii.unhexlify(cipher) @@ -481,9 +481,12 @@ ciphertext=binascii.unhexlify(cipher) plaintext = decrypt(ciphertext,key,AES.MODE_ECB) print ('Cipher: '+ cipher) print ('Password: '+ password) -plaintext = Padding.removePadding(plaintext,mode='CMS') + +plaintext = Padding.removePadding(plaintext.decode(),blocksize=Padding.AES_blocksize,mode='CMS') + print (" decrypt: "+plaintext) ``` +A sample is [here])(https://repl.it/@billbuchanan/ch02ans06#main.py). A sample run gives: