def encryptInCTR(key,data,fileNameToEncrypt): data=bytes(data, 'utf-8') cipher = AES.new(key, AES.MODE_CTR) start = timer() ct_bytes = cipher.encrypt(data) end= timer() print("Time Taken to Encrypt is ",(end-start)) print("Time Taken to Decrypt per byte is ",(end-start)/len(data)) nonce = b64encode(cipher.nonce).decode('utf-8') ct = b64encode(ct_bytes).decode('utf-8') writeFileInBytes(bytes(ct,"utf-8"),fileNameToEncrypt) return nonce