Hello there, how’s it going? (Download script here)
In today’s post, I want to show you a short script to do recursive file encryption in Python 3 – using pyAesCrypt with AES encryption.
Its amazing how powerful this programming language is, really. This is mostly what I wanted to show you guys this time and one of the main reasons I keep coming back time after time to Python.
Using about 20 lines of code, we’re able to encrypt many files in seconds.
Anyway, this post will basically function as a introduction into encryption in Python 3. I had many posts about using encryption in my previous blog with PyCrypto – and I’m still a big fan. However, with Python 2.X in the midst of sunsetting, I figure its time to start looking at newer libraries.
I know there are recent forks for PyCrypto such as PyCryptodome, but in any case, its always good to have some variety in your arsenal.
With that said, pyAesCrypt seems to work rather seamlessly and provides a few different options for functionality – file encryption, stream encryption and in-memory encryption (sounds spicy ay?).
Encryption Using pyAesCrypt
Before we get into the recursive file encryption script, let’s take a look at their brief, yet effective example of basic file encryption: