@synet/keys
Version:
Zero-dependency, secure key generation library. Supports ed25519, x25519, secp256k1, RSA, and WireGuard keys.
29 lines (28 loc) • 1.03 kB
TypeScript
/**
* Generate a CUID2-like identifier using Node.js crypto
*
* This is a simplified, zero-dependency implementation of CUID2 concepts:
* - Uses native Node.js crypto instead of @noble/hashes
* - Maintains similar structure: letter + hash of (time + entropy + counter)
* - Provides collision-resistant, sortable, URL-safe IDs
*
* @param length - Length of the generated ID (default: 24)
* @returns A CUID2-like identifier string
*/
export declare function createId(length?: number): string;
/**
* Convert base64 to base64url encoding
* base64url is the URL-safe variant of base64 used in JWTs
*
* @param base64 - Standard base64 encoded string
* @returns base64url encoded string
*/
export declare function base64ToBase64Url(base64: string): string;
/**
* Convert base64url to base64 encoding
* Converts JWT-style base64url back to standard base64
*
* @param base64url - base64url encoded string
* @returns Standard base64 encoded string
*/
export declare function base64UrlToBase64(base64url: string): string;