Advertisement
rgruber

simpleHash

Mar 29th, 2025
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.23 KB | Source Code | 0 0
  1. function simpleHash(str) {
  2.     let hash = 0;
  3.     for (let i = 0; i < str.length; i++) {
  4.         hash = (hash << 5) - hash + str.charCodeAt(i);
  5.         hash = hash >>> 0; // Convert to unsigned 32-bit
  6.     }
  7.     return hash;
  8. }
  9.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement