#1
(This post was last modified: 18 October, 2024 - 07:03 PM by fireworks. Edited 1 time in total.)
Intro

I decided to make a convenient program for encrypting files without passwords, using a key so that it is stored on the media, so that encrypting / decrypting files / directories is convenient and simple, run the executable, insert the flash drive, and you're done. The symmetric encryption algorithm works quite quickly, and by the way, going crazy and hiding from someone is not the goal of this article. But I have documents and files in which I can write passwords to some services, etc. because you can't remember everything and I would like this data to be hidden from prying eyes, if anything. Photos, videos, scripts - anything. I liked the functionality of this script and I use it for my own purposes, which is why I decided to write it here, someone can use it or finish it and make it cooler and more convenient because the code itself is quite simple.

Preparing the flash drive

In principle, you don't need to prepare anything special. We need a secure flash drive, which we don't just shove into random cars, but store somewhere on keys or something like that, for some special cases) A ​​directory will be created on the USB, in which the key will be. Next, we need to do one manipulation, the thing is that the path to the key will be hardcoded in the script, because I don't see the point in writing extra lines for the cipher/decryption every time. Therefore, I assign a permanent letter to the flash drive in disk management. I do this under Windows, for Linux you need to assign a permanent name for the media, I found this instruction . Thus, under Linux you need to change one line of code, in which the path to the certificate is written. We shove our flash drive, through disk management we assign it a permanent letter, for example X.

[Image: 0BhzjFa.jpeg]

Script

The script uses Fernet from the cryptography module. Everything is quite trivial, three commands per input encrypt/decrypt/generate a new key.


Hidden Content
You must register or login to view this content.



Work


We compile all this into .exe using pyinstaller


Hidden Content
You must register or login to view this content.



And we get a fast and quite easy-to-use script. To use: plug in a flash drive, run .exe

1. Run genkey()
2. Save the resulting key to the flash drive X:\yourkey.key
3. Change the path in the script to yours

def load_key():
# path to the directory and key on USB
return open(r' X:\yourkey.key ', 'rb').read()

4. Run and use, the above manipulations are enough to do once.


leaving a like is much appreciated and help me to keep publishing threads.