From 93920094d58b044a49d9aa67f76838ad209773e7 Mon Sep 17 00:00:00 2001 From: Bill Buchanan Date: Mon, 8 Feb 2021 18:53:28 +0000 Subject: [PATCH] Update possible_ans.md --- unit02_symmetric/lab/possible_ans.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/unit02_symmetric/lab/possible_ans.md b/unit02_symmetric/lab/possible_ans.md index 9624da5..2b27fbb 100644 --- a/unit02_symmetric/lab/possible_ans.md +++ b/unit02_symmetric/lab/possible_ans.md @@ -524,21 +524,19 @@ def decrypt(ciphertext,key, mode): encobj = DES.new(key,mode) return(encobj.decrypt(ciphertext)) -key = hashlib.sha256(password).digest() +key = hashlib.sha256(password.encode()).digest() ciphertext=binascii.unhexlify("f37ee42f2267458d") plaintext = decrypt(ciphertext,key[:8],DES.MODE_ECB) -print plaintext +print (plaintext) -plaintext = Padding.removePadding(plaintext,mode='CMS') -print " decrypt: "+plaintext - - -plaintext=val +plaintext = Padding.removePadding(plaintext.decode(),blocksize=Padding.AES_blocksize,mode='CMS') +print (" decrypt: "+plaintext) ``` +A sample is [here](https://repl.it/@billbuchanan/ch02ans07#main.py). ## F.1 Plaintext: norway