@alwatr/hash-string
Version:
A simple utility to generate a hash string.
21 lines • 854 B
TypeScript
/**
* DJB2 Hash Algorithm - A fast string hashing function.
*
* This implementation is based on Daniel J. Bernstein's popular 'times 33' hash algorithm,
* commonly known as DJB2. It's known for its simplicity, speed, and good distribution properties
* for short strings, making it suitable for general purpose hashing needs.
*
* Performance notes:
* - Uses right-to-left iteration to avoid repeated length lookups
* - Employs bit shifting operations for faster computation
* - Final right shift ensures unsigned 32-bit integer output
*
* @param {string} str - The input string to be hashed
* @returns {number} A 32-bit unsigned integer hash value
*
* @example
* // Returns a numeric hash value
* const hashValue = djb2Hash("hello world");
*/
export declare function djb2Hash(str: string): number;
//# sourceMappingURL=djb2-hash.d.ts.map