Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 9x 9x 107x 1338x 1338x | import { base64encode } from './base64';
/**
* Non cryptographic quality hashing function
* @param data - Hash content
* @example
* P.hash("THIS IS AWESOME") //=> LTU1MjU4ODc4NQ
* @category Utility
*/
export function hash(data: string | undefined): string {
// tslint:disable
return base64encode(
(data || '')
.split('')
.reduce((a, b) => {
a = (a << 5) - a + b.charCodeAt(0);
return a & a;
}, 0)
.toString()
).replace(/=/gm, '');
}
|