AES encryption of files with Python
I am looking to implement a simple project that backs up files and encrypts them using AES.
The normal backing up part is done thanks to how Python handles everything ... however I need to encrypt the data also.
So my question开发者_开发知识库s are:
Is AES the best encryption algorithm for encrypting the files or I can do better?
What is the best Python library for encrypting stuff? I searched and came across M2Crypto and PyCrypto. Any differences/ which one should I favour?
Is this going to be secure? I mean, I will be typing the key everytime I need to encrypt / decrypt and so I will be getting the key from
raw_input
. Is this OK?
If you have any suggestions, feel free to let me know.
Thanks.
Ideally, you would not be at a cipher level in order to secure your data. If nothing else, use an existing, proven secure, framework such as GPG to handle file encryption. This is driven home by your question regarding AES: you haven't even mentioned what cipher modes you were considering (CBC, XTR, CTR, CFB, EBC, etc).
as you have mentioned "AES" without specifying anything else (key-length, modes: cbc, ctr, etc.), I would suggest you to start with pgp (gpg). you can call the gpg command form python and get things done really quick
encrypt
$ gpg -e -r Recipient file
decrypt
$ gpg -d file
see more at http://www.dewinter.com/gnupg_howto/english/GPGMiniHowto.html#toc3
Check pyOpenSSL or PyCrypto.
精彩评论