UNPKG

@rnaga/wp-node

Version:

👉 **[View Full Documentation at rnaga.github.io/wp-node →](https://rnaga.github.io/wp-node/)**

40 lines • 1.91 kB
declare const SODIUM_BASE64_VARIANT_ORIGINAL = 1; declare const SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING = 3; declare const SODIUM_BASE64_VARIANT_URLSAFE = 5; declare const SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING = 7; export { SODIUM_BASE64_VARIANT_ORIGINAL, SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING, SODIUM_BASE64_VARIANT_URLSAFE, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING, }; /** * TypeScript equivalent of PHP's sodium_crypto_generichash() * * @param message - The message to hash * @param key - Optional key for keyed hashing * @param length - Output length in bytes (default: 32, min: 16, max: 64) * @returns Buffer containing the hash */ export declare const sodiumCryptoGenerichash: (message: string | Buffer, key?: string | Buffer | null, length?: number) => Buffer; /** * TypeScript equivalent of PHP's sodium_bin2base64() * Encodes binary data to base64 * * @param data - Binary data to encode * @param variant - Base64 variant (SODIUM_BASE64_VARIANT_ORIGINAL, SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING, SODIUM_BASE64_VARIANT_URLSAFE, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING) * @returns Base64 encoded string */ export declare const sodiumBin2Base64: (data: string | Buffer, variant?: number) => string; /** * Convert base64 string back to binary data * @param base64 - Base64 encoded string * @param variant - Base64 variant that was used for encoding * @returns Buffer containing the decoded binary data */ export declare const sodiumBase642bin: (base64: string, variant?: number) => Buffer; /** * TypeScript equivalent of PHP's hash_equals() * Timing-safe string comparison to prevent timing attacks * * @param known - Known string (expected value) * @param user - User-provided string to compare * @returns true if strings are equal, false otherwise */ export declare const hashEquals: (known: string, user: string) => boolean; //# sourceMappingURL=sodium.d.ts.map