This release is a pre-release and may not be stable for production use.
Redact Secret for Python
Deterministic secret detection and redaction for CPython, over the same Rust core that backs the JavaScript, Rust, and CLI surfaces of Redact Secret. Every built-in detector runs in Rust; there is no pure-Python fallback implementation to drift from it.
The distribution is redact-secret and the import name is
redact_secret. The product name is Redact Secret everywhere; per PEP 503,
redact-secret and redact_secret normalize to the same PyPI project
identity, so no registry fallback name is needed — see
docs/rust-workspace.md.
No release is authorized by the version currently in the development manifests. Installation applies only after a separately approved release.
This directory is the canonical Python binding
decision-release-bindings-in-lockstep requires before the separately created
secret-scan-python GitHub repository (empty today) is archived with a
redirect to here; that prepared redirect text lives in
docs/python-repository-redirect.md.
Install
pip install redact-secret
Wheels are CPython 3.10+ abi3: one wheel per platform serves every supported
interpreter, and installing one needs no Rust toolchain and no compiler. See
Supported wheels. Where no wheel applies, pip falls back to
the source distribution, which does need Rust — see
Building from source.
Use
import redact_secret
findings = redact_secret.scan(text)
redacted = redact_secret.redact(text, findings)
# or, to guarantee the findings and the redacted text agree:
result = redact_secret.scan_and_redact(text)
result.text, result.findings
Ranges on every DetectedFinding and Finding are Unicode code point offsets
(redact_secret.RANGE_UNIT == "unicode-code-points"), so they index a str the
way Python itself does.
For input that arrives in pieces, IncrementalSanitizer sanitizes a bounded
session chunk by chunk. Independently scanning chunks is unsafe, because a
credential may cross any chunk boundary; a session carries the boundary state
that makes it safe. Limits are mandatory and are counted in UTF-8 bytes:
limits = redact_secret.IncrementalLimits(
max_input_bytes=1_000_000,
max_buffered_bytes=32_896,
max_token_bytes=8_192,
max_multiline_bytes=32_768,
)
with redact_secret.IncrementalSanitizer(limits) as session:
first = session.append("api_key=SYNTHETIC_REVOKED_")
second = session.append("INCREMENTAL_VALUE\nordinary text")
final = session.finalize()
safe_text = first.text + second.text + final.text
# api_key=<SECRET_1>\nordinary text
Leaving the with block aborts a session that was not finalized, so whatever it
still retained is discarded. A session's findings carry absolute code point
offsets into the logical whole-session input, so they index "".join(chunks)
exactly as the synchronous API's findings index the same joined string.
policy and formatter callbacks receive only normalized safe metadata, never
the input or a matched value. A callback that raises, or that returns something
other than the documented protocol, never propagates its own error: it becomes
one of the fixed SecretScanError subclasses. There is no custom detector
callback surface.
The package is typed (PEP 561): the wheel ships py.typed and a _native.pyi
stub, so type checkers resolve the API without a stub package.
Supported wheels
| Platform | Architectures | Wheel tag |
|---|---|---|
| manylinux (glibc 2.17+) | x86_64, aarch64 |
cp310-abi3-manylinux_2_17_*.manylinux2014_* |
| musllinux (musl 1.2+) | x86_64, aarch64 |
cp310-abi3-musllinux_1_2_* |
| macOS 11+ | x86_64, arm64 |
cp310-abi3-macosx_* |
| Windows | x64, arm64 |
cp310-abi3-win_* |
Every wheel in that matrix is built and smoke-tested on its own architecture, on CPython 3.10 and 3.14, before a release candidate is accepted; see docs/python-packaging.md.
Building from source
The source distribution needs a Rust toolchain at or above the workspace MSRV
(1.88, Rust 2024 edition). With cargo on PATH, pip install builds it
like any other source install.
Without one, maturin's build backend downloads a toolchain into a local cache
and continues. To refuse that instead and fail immediately with
Cargo metadata failed. Do you have cargo in your PATH?, set:
MATURIN_NO_INSTALL_RUST=1 pip install --no-binary redact-secret redact-secret
Set it in any environment that must not fetch a toolchain over the network.
Development
This directory is a mixed Rust/Python maturin project. The crate is
redact-secret-python, the native module is redact_secret._native, and the pure
Python package lives under python/redact_secret/.
src/lib.rsowns CPython conversions, Unicode code point range conversion, and the synchronousscan/redact/scan_and_redactAPI: immutable finding and result types, sanitized exceptions, and the default policy and formatter helpers (decision-define-runtime-bindings).src/incremental.rsowns the bounded incremental session:IncrementalSanitizer, its mandatoryIncrementalLimits, the lifecycle states, and the incremental policy callback. ItsCodePointIndexconverts the core's absolute UTF-8 byte offsets to the absolute code point offsets a session reports, by recording only where the input's UTF-8 continuation bytes fall, never the characters themselves. Between successful calls it prunes offsets outsidemax_buffered_bytes; while processing a call it also indexes the incoming chunk, and its allocation can retain that peak capacity until the session ends. Bound host chunk sizes as well as session limits.python/redact_secret/__init__.pyre-exports the native module's public surface;python/redact_secret/_native.pyiandpy.typedmark the package as typed.tests/runs against a built extension and exercises the sharedconformance/corpus, Unicode code point conversion, callback failure sanitization, placeholder safety, and determinism. The incremental suites add native-string partition invariance (test_incremental_partitions.py), astral character boundaries (test_incremental_unicode.py), and the canonical lifecycle, limit, callback, and failure-cleanup cases (test_incremental.py). They read the corpus from the repository, so they ship with neither the wheel nor the source distribution.- The
extension-moduleCargo feature is enabled only by maturin, so the crate still links duringcargo test --workspace.
cd bindings/python
python3 -m venv .venv && source .venv/bin/activate
pip install '.[test]' maturin pytest
maturin develop
pytest
Rebuild with maturin develop after any change under src/; pytest imports
the installed extension, not the Rust sources.
Packaging identity, the abi3 contract, and the wheel matrix are declared in
[workspace.metadata.redact-secret] in the root Cargo.toml and enforced by
scripts/check-python-package.py. Build and qualify artifacts with
scripts/qualify-python-wheel.py; see
docs/python-packaging.md.
Release files for redact-secret 0.1.0b1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| redact_secret-0.1.0b1.tar.gz | 101.1 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| redact_secret-0.1.0b1-cp310-abi3-win_arm64.whl | CPython 3.10 | abi3 | Windows ARM64 | Details |
| redact_secret-0.1.0b1-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| redact_secret-0.1.0b1-cp310-abi3-musllinux_1_2_x86_64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ x86-64 | Details |
| redact_secret-0.1.0b1-cp310-abi3-musllinux_1_2_aarch64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ ARM64 | Details |
| redact_secret-0.1.0b1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| redact_secret-0.1.0b1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| redact_secret-0.1.0b1-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| redact_secret-0.1.0b1-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 3.2 MB
Release files / redact_secret-0.1.0b1.tar.gz
| Download URL | redact_secret-0.1.0b1.tar.gz |
|---|---|
| Size | 101.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea375ac4000e70928ab5150f3a1ddef82bdc6f164071a9c862932826bf9c674b
|
|
BLAKE2b-256 checksum How to use checksums |
3f625b2906ec9629959471c330ed6d9f8074399d53e0a3fabb6c22e643de9c9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logRelease files / redact_secret-0.1.0b1-cp310-abi3-win_arm64.whl
| Download URL | redact_secret-0.1.0b1-cp310-abi3-win_arm64.whl |
|---|---|
| Size | 247.0 kB |
| Tags | CPython 3.10 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
742ac215e4ae4acd1812817bf2655e2d90effd6a90a4771d5853c2a1a698a389
|
|
BLAKE2b-256 checksum How to use checksums |
fc76daabcc1eb7519cb111f2d0eecfac9e30774c4cb72d8850907918ee293f20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logRelease files / redact_secret-0.1.0b1-cp310-abi3-win_amd64.whl
| Download URL | redact_secret-0.1.0b1-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 258.8 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
93919df0074142096236e368ca83f01815f123e948d3383c0ec1c167b23a41e9
|
|
BLAKE2b-256 checksum How to use checksums |
3ea495d230a6ac52fa3ec6ec1451f369e896d54a9840ff5284744720f9d6b020
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logRelease files / redact_secret-0.1.0b1-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | redact_secret-0.1.0b1-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 590.8 kB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2d8c14125a04d61eb5093c3f97a1e5fe74e92e0840b3f02facb3273625623272
|
|
BLAKE2b-256 checksum How to use checksums |
48ce266f75b2f9f90df112c2ff5590d30e3cd7e67d4d492674c947b4e184b52d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logRelease files / redact_secret-0.1.0b1-cp310-abi3-musllinux_1_2_aarch64.whl
| Download URL | redact_secret-0.1.0b1-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 552.0 kB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
65846ebacbb109338a6181149ab5188dee56e903a83a3e1dae583f311da7e5e1
|
|
BLAKE2b-256 checksum How to use checksums |
8ee36b8654a2fb67528a42cece30821ff4323d8a0c662a9ca351ab3edeb0b9ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logRelease files / redact_secret-0.1.0b1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | redact_secret-0.1.0b1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 378.9 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
aafde7768448efbcc041c537225101f1e4ed9f03afe06b1dfd07cbd1f795e55d
|
|
BLAKE2b-256 checksum How to use checksums |
1633cc2251c1b03c67adb20b0e427770b878c039ee10db889b6472ff2119b8cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logRelease files / redact_secret-0.1.0b1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | redact_secret-0.1.0b1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 372.7 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
08872334041c4629767c01fae499d98858a589e6882e888fcb3dd0877a68153c
|
|
BLAKE2b-256 checksum How to use checksums |
619bf01a632a4e80d278fd22c7de3d11a7d8673819a57083fe0097b5c8a086e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logRelease files / redact_secret-0.1.0b1-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | redact_secret-0.1.0b1-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 347.6 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e8ea887ced6be4abf5bef0bd758f15b020fa63b4e1d5701e6503ebc13be86766
|
|
BLAKE2b-256 checksum How to use checksums |
fba65e49807742171ab90b8c8cfe4c13d9bc590da971222c17c21bf76362523b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency logRelease files / redact_secret-0.1.0b1-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | redact_secret-0.1.0b1-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 354.4 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
40bc94a8b3bc027cc1c52d52ceb135c312b30eeaff04482d19474ae10481c4cb
|
|
BLAKE2b-256 checksum How to use checksums |
d76cd6e3ef5ea145b9306600761d5a91ee88a0385a910b549c6b9c17645d5b9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.
Transparency log