Skip to main content

flask-enciphers

Encrypted session interface for Flask using enciphers.

Replaces Flask's default signed cookie session with a fully encrypted one.

Version 2.0 note: updated to match enciphers 2.0's AEAD rewrite. ENCIPHERS_STEP no longer exists — see CHANGELOG.md for exactly what changed and why.

Installation

pip install flask-enciphers

Usage

from flask import Flask, session
from flask_enciphers import EnciphersSession

app = Flask(__name__)
EnciphersSession(app)

@app.route("/login")
def login():
    session["user_id"] = 1
    return "logged in"

Application Factory Pattern

from flask_enciphers import EnciphersSession

es = EnciphersSession()

def create_app():
    app = Flask(__name__)
    es.init_app(app)
    return app

Configuration

Key Type Default Description
ENCIPHERS_BACKEND str "AES256_GCM" "AES256_GCM" or "XCHACHA20_POLY1305"
ENCIPHERS_KEY int random Secret key, a 128-bit value
ENCIPHERS_KEY_ENV str None Environment variable for key

If no ENCIPHERS_KEY/ENCIPHERS_KEY_ENV is provided, a random key is generated at startup — fine for local development, but every process in a real deployment needs to share the same key, or sessions won't be portable between them.

Session expiry

If session.permanent is set (giving the cookie a real Max-Age), the same expiry is also bound inside the encrypted token itself — a copy of the cookie can't be replayed past that point even if a client ignores the cookie's own expiration. A non-permanent session cookie (the default) carries no expires_at either, unchanged from before.

License

Apache-2.0 — Copyright 2026 Mejlad Alsubaie

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_enciphers-2.0.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_enciphers-2.0.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file flask_enciphers-2.0.0.tar.gz.

File metadata

  • Download URL: flask_enciphers-2.0.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for flask_enciphers-2.0.0.tar.gz
Algorithm Hash digest
SHA256 0c5ed831a9ac251c6ccc33bc1969855a2f92bfedef5650c8b8f53a419a016458
MD5 329653ddda5f3b9772f51ca5ce6b8f59
BLAKE2b-256 b37a19de41d4d52b1ec81728bbf046547a8d8c4f4a1ff183909ce5b7347d8c93

See more details on using hashes here.

Provenance

The following attestation bundles were made for flask_enciphers-2.0.0.tar.gz:

Publisher: publish.yml on mjlad/flask-enciphers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flask_enciphers-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_enciphers-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec8bb0d9ccb4998503559d3172dec952ec714a7a5e8602fc6a77cf63306c39e8
MD5 f7ea67bfd040461b710673287c4620eb
BLAKE2b-256 c73ff804ccbd4bb0982accafc346a1bd131ab5b521b2b7b9295d8201c1037a66

See more details on using hashes here.

Provenance

The following attestation bundles were made for flask_enciphers-2.0.0-py3-none-any.whl:

Publisher: publish.yml on mjlad/flask-enciphers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page