Task1_8.py 463 B

12345678910111213141516
  1. def decryptInCBC(key,fileNameToDecrypt,iv,fileNameToSavePT):
  2. iv = b64decode(iv)
  3. ct = b64decode(getDataInBytes(fileNameToDecrypt))
  4. cipher = AES.new(key, AES.MODE_CBC, iv)
  5. start=timer()
  6. pt = unpad(cipher.decrypt(ct), AES.block_size)
  7. end=timer()
  8. print("Time Taken to Decrypt is ",end-start)
  9. print("Time Taken to Decrypt per byte is ",(end-start)/len(pt))
  10. pt=pt.decode("utf-8")
  11. writeFile(pt,fileNameToSavePT)
  12. return pt