mnemonic-generator 0.1.1

A library to generate Docker-like mnemonics.
Documentation
  • Coverage
  • 75%
    6 out of 8 items documented4 out of 6 items with examples
  • Size
  • Source code size: 75.38 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.29 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 20s Average build duration of successful builds.
  • all releases: 19s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • akoken/mnemonic-generator
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • akoken

Mnemonic Generator

A lightweight Rust library for generating Docker-like mnemonics.

Installation

Add the following to your Cargo.toml:

[dependencies]
mnemonic-generator = "0.1.0"

Usage

Basic Usage

use mnemonic_generator::MnemonicGenerator;

fn main() {
    // Create a generator with default words
    let generator = MnemonicGenerator::new();

    // Generate a mnemonic with default underscore separator
    match generator.generate() {
        Ok(mnemonic) => println!("Generated mnemonic: {}", mnemonic),
        Err(e) => eprintln!("Error: {}", e)
    }
}

Custom Word Lists

use mnemonic_generator::MnemonicGenerator;

fn main() {
    // Create a generator with custom words
    let generator = MnemonicGenerator::with_words(
        vec!["amazing".to_string(), "legend".to_string()],
        vec!["jordan".to_string(), "larry".to_string()]
    );

    // Generate a mnemonic with a custom separator
    match generator.generate_with_separator("-") {
        Ok(mnemonic) => println!("Custom mnemonic: {}", mnemonic),
        Err(e) => eprintln!("Error: {}", e)
    }
}

Error Handling

The library provides a MnemonicError enum to handle potential generation errors:

  • EmptyWordList: Occurs when no words are available for generating a mnemonic

License

[MIT License]