Skip to content

Instantly share code, notes, and snippets.

@zrobit
Created February 2, 2017 02:34
Show Gist options
  • Select an option

  • Save zrobit/cfb2eeea6349d2d3054f9f2feec4b98c to your computer and use it in GitHub Desktop.

Select an option

Save zrobit/cfb2eeea6349d2d3054f9f2feec4b98c to your computer and use it in GitHub Desktop.
KISS hash generetor (don't use if avoid hash collision is super necessary)
const ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
const LENGTH = 8;
function hash() {
let tmp = '';
for (let i = 0; i < LENGTH; i++) {
tmp += ALPHABET.charAt(Math.floor(Math.random() * ALPHABET.length));
}
return tmp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment