File encryption tool
Encrypt and decrypt files with a password using authenticated encryption and a proper key derivation function.
Intermediateâą 6â8 hoursđĒ 7 stepsPythoncryptography
What you'll learn
- âSymmetric encryption (AES-GCM / Fernet)
- âKey derivation (scrypt/PBKDF2) and salts
- âWhy you never invent your own crypto
What you'll build
- âencrypt file â file.enc with a password
- âdecrypt with the right password only
- âDetects tampering
- âWorks for large files
Step-by-step guide
- 1
Install
pip install cryptography (do not write your own cipher).
- 2
Derive a key
Random 16-byte salt from os.urandom; derive a 32-byte key with Scrypt (or PBKDF2HMAC with many iterations).
- 3
Encrypt
AESGCM(key).encrypt(nonce, data, None) with a random 12-byte nonce; write salt + nonce + ciphertext.
- 4
Decrypt
Read salt and nonce, derive the key, decrypt; an InvalidTag exception means wrong password or tampered file.
- 5
Large files
Encrypt in chunks (each chunk with its own nonce and index) or use streaming with a library that supports it.
- 6
Safe CLI
Ask for the password with getpass (not as a command-line argument), confirm it twice.
- 7
Explain
README: what is protected, what is not (lost password = lost file).
đ Make it stand out
- +Encrypt a whole folder into one archive
- +GUI with Tkinter
- +Public-key mode for sharing