Simple String Hash

Generate a simple numeric hash from a string.

Code

Utilities
let hash = 0;
for (let i = 0; i < str.length; i++) {
  hash = ((hash << 5) - hash) + str.charCodeAt(i);
  hash |= 0;
}
return Math.abs(hash).toString();

Parameters

String to hash.

Browser·fetch() may be limited by CORS

More JavaScript Snippets