Skip to main content

secretgenerator-py (Python wrapper)

pypi python

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 (not secretgenerator) because a secret-generator package already exists and PyPI fuzzy-matches short variants. The import name is secretgenerator_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)

Source distribution for secretgenerator-py 2.1.0
File Size Uploaded
secretgenerator_py-2.1.0.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for secretgenerator-py 2.1.0
File Interpreter ABI Platform
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 log

Release 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

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page