Skip to content

Instantly share code, notes, and snippets.

@remarkablemark
Last active September 19, 2016 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remarkablemark/fd0837438d136e18c8e8eac559cd004a to your computer and use it in GitHub Desktop.
Save remarkablemark/fd0837438d136e18c8e8eac559cd004a to your computer and use it in GitHub Desktop.
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