window.newId = -># create a number based on the usernameunless window.userNumber?window.userNumber = 0for c,i in window.MyNamespace.userNamechar = window.MyNamespace.userName.charCodeAt(i)window.MyNamespace.userNumber+=char((window.MyNamespace.userNumber + Math.floor(Math.random() * 1e15) + new Date().getMilliseconds()).toString(36)).toUpperCase()
String.prototype.hashLarge = function() {var self = this, range = Array(this.length);for(var i = 0; i < this.length; i++) {range[i] = i;}return Array.prototype.reduce.call(range, function(sum, i) {return sum + self.charCodeAt(i);}, 0).toString(16);}
'One time, I hired a monkey to take notes for me in class. I would just sit back with my mind completely blank while the monkey scribbled on little pieces of paper. At the end of the week, the teacher said, "Class, I want you to write a paper using your notes." So I wrote a paper that said, "Hello! My name is Bingo! I like to climb on things! Can I have a banana? Eek, eek!" I got an F. When I told my mom about it, she said, "I told you, never trust a monkey!"'.hashLarge()"9ce7"
function getHash(str, algo = "SHA-256") {let strBuf = new TextEncoder().encode(str);return crypto.subtle.digest(algo, strBuf).then(hash => {window.hash = hash;// here hash is an arrayBuffer,// so we'll connvert it to its hex versionlet result = '';const view = new DataView(hash);for (let i = 0; i < hash.byteLength; i += 4) {result += ('00000000' + view.getUint32(i).toString(16)).slice(-8);}return result;});}
getHash('hello world').then(hash => {console.log(hash);});
//Credits (modified code): Bob Jenkins (http://www.burtleburtle.net/bob/hash/doobs.html)//See also: https://en.wikipedia.org/wiki/Jenkins_hash_function//Takes a string of any size and returns an avalanching hash string of 8 hex characters.function jenkinsOneAtATimeHash(keyString){let hash = 0;for (charIndex = 0; charIndex < keyString.length; ++charIndex){hash += keyString.charCodeAt(charIndex);hash += hash << 10;hash ^= hash >> 6;}hash += hash << 3;hash ^= hash >> 11;//4,294,967,295 is FFFFFFFF, the maximum 32 bit unsigned integer value, used here as a mask.return (((hash + (hash << 15)) & 4294967295) >>> 0).toString(16)};