- hashCode
- simpleHash
- hash-sum
- js-xxhash Web Assembly version
- object-hash
- SubtleCrypto digest (browser built-in SHA1, SHA256)
- SHA1 (Stanford Javascript Crypto Library)
- SHA256 (Stanford Javascript Crypto Library)
// arbitrary length numeric value
const uid = (length=16) => {
return parseInt(Math.ceil(Math.random() * Date.now()).toPrecision(length).toString().replace(".", ""));
}
// long numeric value
const uid = function () {
return Date.now().toString() + Math.floor(Math.pow(10, 12) + Math.random() * 9*Math.pow(10, 12));
}
// UUID v4 eg. 9f3bbc61-26ca-447a-89ac-f5c14d34d1cb
function uuidv4 () {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}