secretgenerator-py (Python wrapper)
Auditable random credential generator for AI agents and machine-readable
pipelines. This Python package wraps the
secretgenerator CLI
and exposes its stable schema-v1 JSON output as Python dicts.
Install
The Python package and the CLI binary install separately:
pip install secretgenerator-py
The PyPI distribution is named
secretgenerator-py(notsecretgenerator) because asecret-generatorpackage already exists and PyPI fuzzy-matches short variants. The import name issecretgenerator_py.
Then install the CLI once with whichever method fits your environment:
npm install -g @secretgenerator/cli
# or
brew install rafaelperoco/tap/secretgenerator
# or
go install github.com/rafaelperoco/secretgenerator/cmd/secretgenerator@latest
Quick start
import secretgenerator_py as sg
pw = sg.password(length=24, charset="alphanum-symbols-v1",
require_classes="lower,upper,digit,symbol")
print(pw["password"], "—", pw["entropy_bits"], "bits")
phrase = sg.passphrase(words=8, separator="-")
print(phrase["password"])
token = sg.api_key(length=40, prefix="sk_live")
print(token["password"])
bits = sg.entropy("Tr0ub4dor&3")["entropy_bits"]
print(f"that pasword has {bits:.1f} bits")
Every function returns a parsed schema-v1 dict with the same shape as
the CLI's --json output (see
schemas/output-v1.json).
Error handling
try:
sg.password(length=4) # below the 80-bit floor
except sg.SecretgeneratorError as e:
if e.code == "E_ENTROPY_TOO_LOW":
# Stable code; safe to branch on.
...
The code attribute exposes a stable identifier from the CLI's error
envelope (E_ENTROPY_TOO_LOW, E_CHARSET_EMPTY, E_CLASS_IMPOSSIBLE,
E_INVALID_ARGS, E_RNG_FAILURE).
Why a wrapper instead of a pure-Python implementation?
Cryptographic primitives belong in audited binaries with reproducible builds and SLSA provenance, not duplicated across language wrappers. The CLI is signed end-to-end with cosign keyless (Sigstore/Fulcio + GitHub OIDC) and ships SLSA Level 3 attestation. This wrapper is a thin transport — it parses JSON.
Metadata
Release files for secretgenerator-py 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| secretgenerator_py-2.1.0.tar.gz | 5.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| secretgenerator_py-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.8 kB
Release files / secretgenerator_py-2.1.0.tar.gz
| Download URL | secretgenerator_py-2.1.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d89ce8a7669048fdf70bbf2a5d3d043387a44ee809b29a70d00c7e218a34d24
|
|
BLAKE2b-256 checksum How to use checksums |
4b63380548642b9f5ed7ef6da40861d4803e760977cc1b81fb53c57e5e74b590
|
| 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 Oct 14, 2026.
Transparency logRelease files / secretgenerator_py-2.1.0-py3-none-any.whl
| Download URL | secretgenerator_py-2.1.0-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d69343cac1b0fa9d24795c5cf5605aa32793f797ec6fe2c56bc92f5e52a2751
|
|
BLAKE2b-256 checksum How to use checksums |
3044cff35561f070b0945e622a2053505b1a7b4950de35e0c410148331a76663
|
| 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 Oct 14, 2026.
Transparency log