encryption - Encrypt file in python with aes -


i want encrypt , decrypt file (any type of file) using aes 128 in cbc mode in python.

i quite new cryptography , have tried tutorials work on texts, , need files.

could suggest me solution?

a quick google search guided me crypto package. comes ipython using, installation should trivial anyway.

i repost example here information.

>>> crypto.cipher import aes >>> obj = aes.new('this key123', aes.mode_cbc, 'this iv456') >>> message = "the answer no" >>> ciphertext = obj.encrypt(message) >>> ciphertext '\xd6\x83\x8dd!vt\x92\xaa`a\x05\xe0\x9b\x8b\xf1' >>> obj2 = aes.new('this key123', aes.mode_cbc, 'this iv456') >>> obj2.decrypt(ciphertext) 'the answer no' 

here documentation of aes.

if try encrypt file, can either use openssl or python solution using crypto contributed thijs. click here more information.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -