Brian Johns
Brian Johns

Reputation: 31

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 questions are:

  1. Is AES the best encryption algorithm for encrypting the files or I can do better?

  2. What is the best Python library for encrypting stuff? I searched and came across M2Crypto and PyCrypto. Any differences/ which one should I favour?

  3. 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.

Upvotes: 3

Views: 2237

Answers (3)

OneOfOne
OneOfOne

Reputation: 99351

Check pyOpenSSL or PyCrypto.

Upvotes: -1

Tzury Bar Yochay
Tzury Bar Yochay

Reputation: 9004

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

Upvotes: 1

Yann Ramin
Yann Ramin

Reputation: 33197

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).

Upvotes: 2

Related Questions