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
enciphers2.0's AEAD rewrite.ENCIPHERS_STEPno 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_ENVis 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c5ed831a9ac251c6ccc33bc1969855a2f92bfedef5650c8b8f53a419a016458
|
|
| MD5 |
329653ddda5f3b9772f51ca5ce6b8f59
|
|
| BLAKE2b-256 |
b37a19de41d4d52b1ec81728bbf046547a8d8c4f4a1ff183909ce5b7347d8c93
|
Provenance
The following attestation bundles were made for flask_enciphers-2.0.0.tar.gz:
Publisher:
publish.yml on mjlad/flask-enciphers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flask_enciphers-2.0.0.tar.gz -
Subject digest:
0c5ed831a9ac251c6ccc33bc1969855a2f92bfedef5650c8b8f53a419a016458 - Sigstore transparency entry: 2333204305
- Sigstore integration time:
-
Permalink:
mjlad/flask-enciphers@553d441b209730eb0585bf8decb27f0e42017fa1 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/mjlad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@553d441b209730eb0585bf8decb27f0e42017fa1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file flask_enciphers-2.0.0-py3-none-any.whl.
File metadata
- Download URL: flask_enciphers-2.0.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec8bb0d9ccb4998503559d3172dec952ec714a7a5e8602fc6a77cf63306c39e8
|
|
| MD5 |
f7ea67bfd040461b710673287c4620eb
|
|
| BLAKE2b-256 |
c73ff804ccbd4bb0982accafc346a1bd131ab5b521b2b7b9295d8201c1037a66
|
Provenance
The following attestation bundles were made for flask_enciphers-2.0.0-py3-none-any.whl:
Publisher:
publish.yml on mjlad/flask-enciphers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flask_enciphers-2.0.0-py3-none-any.whl -
Subject digest:
ec8bb0d9ccb4998503559d3172dec952ec714a7a5e8602fc6a77cf63306c39e8 - Sigstore transparency entry: 2333204336
- Sigstore integration time:
-
Permalink:
mjlad/flask-enciphers@553d441b209730eb0585bf8decb27f0e42017fa1 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/mjlad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@553d441b209730eb0585bf8decb27f0e42017fa1 -
Trigger Event:
push
-
Statement type: