Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A JavaScript hash generator.
'use strict';
/**
* Generates a hash based on Date.
*
* @param {Number} [radix=32] - The radix between 2 to 36.
* @return {String} - The hash.
*/
function hash(radix) {
radix = parseInt(radix);
if (!(radix > 1 && radix < 37)) {
radix = 36; // default
}
return Date.now().toString(radix);
}
// hash(32)
// "1asq7hi7d"
// hash(16)
// "157347954e3"
module.exports = hash;
{
"name": "hash-generator",
"version": "0.0.1",
"description": "",
"author": "Mark <mark@remarkablemark.org>",
"main": "hash-generator.js",
"private": true,
"license": "MIT"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment