micro-key-producer
Version:
Produces secure passwords & keys for WebCrypto, SSH, PGP, SLIP10, OTP and many others
36 lines • 1.53 kB
TypeScript
/*! micro-key-producer - MIT License (c) 2024 Paul Miller (paulmillr.com) */
/**
* Utilities.
* @module
*/
import { randomBytes as nobleRandomBytes } from '@noble/hashes/utils.js';
import { type Coder, type CoderType } from 'micro-packed';
/**
* Secure random byte generator re-exported from `@noble/hashes/utils`.
* @example
* Generate fresh entropy before deriving one of the deterministic key formats.
* ```ts
* import { randomBytes } from 'micro-key-producer/utils.js';
* randomBytes(32);
* ```
*/
export declare const randomBytes: typeof nobleRandomBytes;
/**
* Base64-armored values are commonly used in cryptographic applications, such as PGP and SSH.
* @param name - The name of the armored value.
* @param lineLen - Maximum line length for the armored value (e.g., 64 for GPG, 70 for SSH).
* @param inner - Inner CoderType for the value.
* @param checksum - Optional checksum function.
* @returns Coder representing the base64-armored value.
* @throws On wrong argument types. {@link TypeError}
* @throws On invalid armor names or line lengths. {@link RangeError}
* @example
* Wrap a packed coder in an ASCII armor envelope.
* ```ts
* import * as P from 'micro-packed';
* import { base64armor } from 'micro-key-producer/utils.js';
* base64armor('MESSAGE', 64, P.string(null)).encode('hello');
* ```
*/
export declare function base64armor<T>(name: string, lineLen: number, inner: CoderType<T>, checksum?: (data: Uint8Array) => Uint8Array): Coder<T, string>;
//# sourceMappingURL=utils.d.ts.map