import { type BinaryLike, type BinaryToTextEncoding } from 'node:crypto'; import type { CryptoAlgorithm } from './type.js'; /** * Represents the configuration for a hash generator. */ export interface HashGeneratorConfig { /** * The prefix to be added to the generated hash. */ prefix: string; /** * The algorithm used for hashing. */ algorithm: CryptoAlgorithm; /** * The encoding used for the generated hash. */ encoding: BinaryToTextEncoding; /** * The length of the CRC (Cyclic Redundancy Check) value. */ crcLength: number; } /** * Secure **self-validate** hash generator. */ export declare class AlwatrHashGenerator { config: HashGeneratorConfig; /** * Creates a new instance of the AlwatrHashGenerator class. * @param config The configuration for the hash generator. */ constructor(config: HashGeneratorConfig); /** * Generate a random hash. * @returns The generated hash. * @example * ```typescript * const clientId = hashGenerator.generateRandom(); * ``` */ generateRandom(): string; /** * Generate a **self-validate** random hash. * @returns The generated self-validated hash. * @example * ```typescript * const userId = hashGenerator.generateRandomSelfValidate(); * ``` */ generateRandomSelfValidate(): string; /** * Generate a hash from data. * @param data - The data to generate the hash from. * @returns The generated hash. * @example * ```typescript * const crcHash = hashGenerator.generate(data); * ``` */ generate(data: BinaryLike): string; /** * Generate a crc hash. * @param data - The data to generate the crc hash from. * @returns The generated crc hash. */ generateCrc(data: BinaryLike): string; /** * Generate a **self-validate** hash from data. * @param data - The data to generate the self-validated hash from. * @returns The generated self-validated hash. * @example * ```typescript * const userId = hashGenerator.generateSelfValidate(data); * ``` */ generateSelfValidate(data: BinaryLike): string; /** * Verify if the generated hash matches the provided hash. * @param data - The data to verify. * @param hash - The hash to compare against. * @returns `true` if the hash is verified, `false` otherwise. * @example * ```typescript * if (!hashGenerator.verify(data, hash)) { * new Error('data_corrupted'); * } * ``` */ verify(data: BinaryLike, hash: string): boolean; /** * Verify a **self-validate** hash to check if it was generated by this class (with the same options). * @param hash - The self-validated hash to verify. * @returns `true` if the hash is verified, `false` otherwise. * @example * ```typescript * if (!hashGenerator.verifySelfValidate(hash)) { * new Error('invalid_hash'); * } * ``` */ verifySelfValidate(hash: string): boolean; } //# sourceMappingURL=hash.d.ts.map