Expand description
§genrs Library
A versatile key and UUID generation library that allows you to:
- Generate secure random keys of arbitrary length
- Encode keys in either hexadecimal (
Hex) or Base64 (Base64) format - Generate UUIDs of any version (V1, V3, V4, V5)
§Example usage
use genrs_lib::{encode_key, generate_key, generate_uuid, EncodingFormat, UuidVersion};
// Generate a random key
let key = generate_key(32);
let encoded_key = encode_key(key, EncodingFormat::Base64).unwrap();
println!("Generated and encoded key: {}", encoded_key);
// Generate a UUID V4
let uuid_v4 = generate_uuid(UuidVersion::V4, None, None).unwrap();
println!("Generated UUID V4: {}", uuid_v4);§Features
- Key Generation: Uses a cryptographically secure random number generator (CSPRNG) to generate random keys of arbitrary length.
- Key Encoding: Supports
HexandBase64encoding formats for ease of transmission and storage. - UUID Generation: Create universally unique identifiers (UUIDs) for V1 (timestamp-based), V3 (namespace + name, MD5), V4 (random), and V5 (namespace + name, SHA-1).
§Referenced Libraries
Enums§
- Encoding
Format - Enum to represent the encoding format for the key.
- Uuid
Version - Enum to represent UUID versions.
Functions§
- encode_
key - Encodes the given key into the specified format (
HexorBase64). - generate_
key - Generates a random key of the given length in bytes.
- generate_
uuid - Generates a UUID of the specified version.