Secure Crypt protects every file and folder with AES-256-GCM — an authenticated encryption scheme that simultaneously guarantees confidentiality, integrity, and authenticity. Encryption keys are never stored on disk; instead, they are derived fresh from your password on every operation using PBKDF2-HMAC-SHA256 with 600,000 iterations. This page explains each cryptographic primitive in detail, how they are combined, and what the security guarantees mean in practice.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Anzi001/Secure-Crypt/llms.txt
Use this file to discover all available pages before exploring further.
Cryptographic Primitives
Secure Crypt uses three well-vetted, audited primitives from the PyCAcryptography library:
| Primitive | Purpose | Standard |
|---|---|---|
| PBKDF2-HMAC-SHA256 | Derives a 256-bit encryption key from your password | NIST SP 800-132 |
| AES-256-GCM | Encrypts and authenticates the plaintext | NIST SP 800-38D |
os.urandom | Generates cryptographically random salt and nonce | OS CSPRNG |
cryptography.hazmat.primitives, which wraps OpenSSL under the hood.
The
cryptography library is published by the Python Cryptographic Authority (PyCA) and is regularly audited. It is available at https://cryptography.io. Secure Crypt lists it as its only runtime dependency in requirements.txt.Key Derivation
Before any encryption or decryption can take place, your password must be transformed into a fixed-length cryptographic key. Secure Crypt uses PBKDF2-HMAC-SHA256 for this purpose.| Parameter | Value |
|---|---|
| Algorithm | HMAC-SHA256 |
| Iterations | 600,000 |
| Output key length | 32 bytes (256 bits) |
| Salt | 16-byte random value stored at bytes 1–16 of the file header |
key is used directly as the AES-256 key and is never persisted to disk.
Encryption
With the 32-byte key in hand, Secure Crypt encrypts the plaintext using AES-256-GCM viacryptography.hazmat.primitives.ciphers.aead.AESGCM.
| Parameter | Value |
|---|---|
| Algorithm | AES-GCM |
| Key size | 32 bytes (256 bits) |
| Nonce size | 12 bytes (96 bits), randomly generated per encryption |
| Authentication tag | 16 bytes, appended to the ciphertext by AESGCM.encrypt() |
| Additional authenticated data (AAD) | None (None) |
ciphertext (which includes the authentication tag) is written to the file starting at byte offset 29, immediately after the 29-byte header containing the flag, salt, and nonce.
Authentication
AES-GCM is an Authenticated Encryption with Associated Data (AEAD) scheme. This means the ciphertext is not just encrypted — it is also protected by a cryptographic authentication tag. Any modification to the ciphertext bytes, even flipping a single bit, will cause decryption to fail. When Secure Crypt decrypts a file,AESGCM.decrypt() recomputes and verifies the authentication tag internally. If the tag does not match — due to a wrong password, a corrupted file, or any form of tampering — the cryptography library raises an InvalidTag exception. Secure Crypt catches this exception and displays:
“Incorrect password or corrupted data.”This behavior is by design. There is no way to partially decrypt or skip authentication.
Forward Secrecy of Ciphertexts
Every encryption operation — whether a first-time lock or a Quick View re-lock — generates a completely fresh salt and nonce usingos.urandom:
- The same plaintext encrypted twice with the same password produces two unrelated ciphertexts.
- An attacker who observes multiple versions of a locked file cannot correlate them cryptographically.
- Re-locking after Quick View always produces a fresh ciphertext, not a re-use of the previous one.