Skip to main content

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.

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.

Cryptographic Primitives

Secure Crypt uses three well-vetted, audited primitives from the PyCA cryptography library:
PrimitivePurposeStandard
PBKDF2-HMAC-SHA256Derives a 256-bit encryption key from your passwordNIST SP 800-132
AES-256-GCMEncrypts and authenticates the plaintextNIST SP 800-38D
os.urandomGenerates cryptographically random salt and nonceOS CSPRNG
All cryptographic operations go through 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.
ParameterValue
AlgorithmHMAC-SHA256
Iterations600,000
Output key length32 bytes (256 bits)
Salt16-byte random value stored at bytes 1–16 of the file header
The 600,000-iteration count meets and exceeds the NIST-recommended minimum for PBKDF2-SHA256 as of 2023. Each iteration adds computational cost for an attacker attempting a brute-force or dictionary attack, while the per-file random salt prevents precomputed rainbow-table attacks.
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC

kdf = PBKDF2HMAC(
    algorithm=hashes.SHA256(),
    length=32,
    salt=salt,       # 16-byte value from the file header (bytes 1–16)
    iterations=600000
)
key = kdf.derive(password.encode())
The derived 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 via cryptography.hazmat.primitives.ciphers.aead.AESGCM.
ParameterValue
AlgorithmAES-GCM
Key size32 bytes (256 bits)
Nonce size12 bytes (96 bits), randomly generated per encryption
Authentication tag16 bytes, appended to the ciphertext by AESGCM.encrypt()
Additional authenticated data (AAD)None (None)
from cryptography.hazmat.primitives.ciphers.aead import AESGCM

aesgcm = AESGCM(key)
ciphertext = aesgcm.encrypt(nonce, plaintext, None)  # aad=None
# ciphertext includes the 16-byte authentication tag at the end
The resulting 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 using os.urandom:
ns, nn = os.urandom(16), os.urandom(12)
# ns = new 16-byte salt
# nn = new 12-byte nonce
These values are written into the new file header before encryption. As a result:
  • 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.
Secure Crypt does not support zero-knowledge proofs, password hints, or any form of password recovery. The password is the sole input to key derivation. If the password is lost, the encrypted data is permanently and irrecoverably inaccessible — there is no backdoor, escrow, or reset mechanism.

Build docs developers (and LLMs) love