UNPKG

xypriss-security

Version:

Advanced High-Performance Security Framework. Military-grade encryption, post-quantum resilience, and fortified data structures.

64 lines 2.35 kB
/*************************************************************************** * XyPriss Security Core - Random Class ****************************************************************************/ import { Bridge } from "./bridge"; import { SecureBuffer } from "./SecureBuffer"; import { SecureTokenOptions } from "../types"; /** * ### Random Class * * Cryptographically secure random number and token generation. */ export declare class Random { /** * Generates a readable secure random token with specified constraints. * * @param length - The desired length of the generated token. * @param options - Configuration for character sets and entropy levels. * @returns A secure random string token. */ static generateToken(length?: number, options?: SecureTokenOptions): SecureBuffer; /** * Generates a numeric OTP of specified length. */ static generateOTP(digits?: number): string; /** * Generates a secure random integer in [0, max). */ static getRandomInt(max: number): number; /** * Generates a buffer of cryptographically secure random bytes. * * @param length - The number of random bytes to generate. * @returns A SecureBuffer containing random bytes. */ static getRandomBytes(length: number): SecureBuffer; /** * Generates a secure random integer in [min, max). * If only one argument is provided, it's treated as the maximum. * * @param minOrMax - The minimum value (inclusive) or maximum if second arg missing. * @param max - The maximum value (exclusive). */ static Int(minOrMax: number, max?: number): number; /** * Alias for getRandomBytes. */ static Bytes(...args: Parameters<typeof Bridge.getRandomBytes>): Uint8Array<ArrayBuffer>; /** * Alias for generateOTP. */ static OTP(...args: Parameters<typeof Bridge.generateOTP>): string; /** * Randomly picks an item from an array using cryptographically secure random numbers. * * @param arr - The array to pick from. * @returns A random item from the array. */ static pick<T>(arr: T[]): T; /** * Alias for generateToken. */ static generateSecureToken(...args: Parameters<typeof Random.generateToken>): SecureBuffer; } //# sourceMappingURL=Random.d.ts.map