Task2_8.py 461 B

123456789101112131415
  1. def decryptInCTR(key,fileNameToDecrypt,nonce,fileNameToSavePT):
  2. ct = b64decode(getDataInBytes(fileNameToDecrypt))
  3. nonce = b64decode(nonce)
  4. cipher = AES.new(key, AES.MODE_CTR, nonce=nonce)
  5. start=timer()
  6. pt = cipher.decrypt(ct)
  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