AES file encryption using Python

I am looking to implement a simple project that backs up files and encrypts them using AES.

The normal part of the backup is done thanks to the way Python handles everything ... however, I also need to encrypt the data.

So my questions are:

  • Is AES the best encryption algorithm for file encryption, or can I do better?

  • What is the best Python library for encryption? I searched and stumbled upon M2Crypto and PyCrypto. Any differences / which I should approve?

  • Will it be safe? I mean, I will dial the key every time I need to encrypt / decrypt, and so I will get the key from raw_input. This is normal?

If you have any suggestions, feel free to let me know.

Thank.

+3
source share
3 answers

Ideally, you will not be at the encryption level to protect your data. If nothing else, use an existing, trusted secure infrastructure such as GPG to handle file encryption. This is related to your question regarding AES: you did not even indicate which encryption modes you are considering (CBC, XTR, CTR, CFB, EBC, etc.).

+2
source

as you mentioned "AES" without specifying anything (key length, modes: cbc, ctr, etc.), I suggest you start with pgp (gpg). you can call the python form of the gpg command and quickly do something very fast

encrypt

$ gpg -e -r Recipient file

decrypt

$ gpg -d file

. http://www.dewinter.com/gnupg_howto/english/GPGMiniHowto.html#toc3

+1
-1

Source: https://habr.com/ru/post/1780505/


All Articles