12345678910111213 |
- def encryptInCBC(key,data,fileNameToEncrypt):
- data=bytes(data, 'utf-8')
- cipher = AES.new(key, AES.MODE_CBC)
- start = timer()
- ct_bytes = cipher.encrypt(pad(data, AES.block_size))
- end= timer()
- print("Time Taken to Encrypt is "+str(end-start))
- print("Time Taken to Encrypt per byte is ",(end-start)/len(data))
- iv = b64encode(cipher.iv).decode('utf-8')
- ct = b64encode(ct_bytes).decode('utf-8')
- writeFileInBytes(bytes(ct,"utf-8"),fileNameToEncrypt)
- return iv
|