1 unstable release

new 0.1.1 Feb 15, 2025

#395 in Command-line interface

Download history 100/week @ 2025-02-11

100 downloads per month

Apache-2.0

17KB
208 lines

genrs

genrs is a command-line tool for generating random keys, UUIDs, and encoding them in different formats. It supports generating custom-length keys, common key presets, and UUIDs of various versions.

Usage

To use genrs, run the following command:

genrs [OPTIONS]

Options

Key Generation Mode (default)

  • -p, --preset <PRESET>

    • Specifies a preset for commonly used keys.
    • Possible values: aes128, aes192, aes256, hmac256, hmac512, jwt256, jwt512, apikey128, apikey256
    • Example: genrs --preset aes256
  • -f, --format <FORMAT>

    • Specifies the encoding format for the generated key.
    • Possible values: hex, base64
    • Default: hex
  • -l, --length <LENGTH>

    • Specifies the length of the generated key in bytes.
    • Default: 32 (i.e., 256 bits)
    • Ignored if a preset is used.

UUID Generation Mode

  • -m, --mode <MODE>

    • Specifies the mode: key for key generation, uuid for UUID generation.
    • Default: key
  • -u, --uuid-version <UUID_VERSION>

    • Specifies the UUID version.
    • Possible values: v1, v3, v4, v5
    • Default: v4
  • -n, --namespace <NAMESPACE>

    • Specifies the namespace UUID for UUID V3 or V5.
  • -N, --name <NAME>

    • Specifies the name for UUID V3 or V5.

General Options

  • -h, --help

    • Print help information about genrs.
  • -V, --version

    • Print the version of genrs.

Examples

Key Generation

Generate a 32-byte key in hexadecimal format (default):

genrs

Generate a 64-byte key in base64 format:

genrs -f base64 -l 64

Generate a 16-byte key using the aes128 preset:

genrs --preset aes128

UUID Generation

Generate a version 4 UUID:

genrs --mode uuid

Generate a version 1 UUID:

genrs --mode uuid --uuid-version v1

Generate a version 3 UUID with a namespace and name:

genrs --mode uuid --uuid-version v3 --namespace <UUID> --name "example"

Installation

To install genrs, you can build it from source using Cargo:

cargo build --release

The resulting binary will be located in the target/release directory. You can move it to a directory in your PATH for easy access.

License

genrs is licensed under the Apache License, Version 2.0. See the LICENSE file for details.

Dependencies

~3–12MB
~149K SLoC