Skip to main content

Crate secretgenerator

Crate secretgenerator 

Source
Expand description

Rust bindings for the auditable secretgenerator CLI.

Each function in this crate corresponds to a CLI subcommand. The function shells out to secretgenerator, parses the schema-v1 JSON envelope, and returns a typed Output. When the CLI exits non-zero a Error::Cli is returned with the structured error envelope attached so callers can branch on stable error codes (E_ENTROPY_TOO_LOW, E_CHARSET_EMPTY, E_CLASS_IMPOSSIBLE, etc.) rather than parsing free-form messages.

§Install the binary

npm install -g @secretgenerator/cli
# or: brew install rafaelperoco/tap/secretgenerator
# or: go install github.com/rafaelperoco/secretgenerator/cmd/secretgenerator@latest

§Quick start

use secretgenerator::{password, PasswordOptions};

let out = password(
    PasswordOptions::default()
        .length(24)
        .charset("alphanum-symbols-v1")
        .require_classes("lower,upper,digit,symbol"),
)?;
println!("{} ({} bits)", out.password, out.entropy_bits);

Structs§

ApiKeyOptions
CliFailure
Detailed CLI failure payload, boxed in Error::Cli so the enum stays small.
CrackTimeEstimate
One attacker scenario applied to a credential’s entropy.
ErrorDetail
ErrorEnvelope
Structured error envelope emitted by the CLI when a subcommand fails. The code field is the part of the contract you are meant to branch on.
EstimateOutput
Schema-v1 envelope for the entropy subcommand. The CLI does not echo the password it analyzes, so Output would not deserialize cleanly — this struct keeps just the fields the subcommand populates.
Output
Schema-v1 envelope returned by every generation subcommand.
PassphraseOptions
PasswordOptions
Builder for password.
PinOptions
SecretOptions

Enums§

Error
Error type returned by every function in this crate.

Constants§

SCHEMA_VERSION
The schema version this crate is pinned to.

Functions§

api_key
entropy
Estimate the entropy and crack time of an existing string. The candidate is piped on stdin so it never appears in argv.
passphrase
password
Generate a random password.
pin
secret