fnv-time

0.1.0 • Public • Published

fnv-time

NPM version

Time-dependent unique ID generator based on the FNV-1a Hashing algorithm.

The ids generated are composed of a prefix letter or string, a timestamp (encoded in base 36), and the fnv hash of a given value. FNV-1a hashes generated by fnv-plus make these ids safe to use for server-side record lookups due its uniqueness properties.

Install

$ npm install fnv-time --save

Usage

var fnvtime = require('fnv-time');
var hash = fnvtime();
 
console.log(hash('hello world!'));
// base36(Date.now()) + 782ded88cd5a2672
 
console.log(hash('hello world!', new Date('2014-12-17T00:45:32.599Z')));
// i3rz9ttj782ded88cd5a2672
 
var prefixedHash = fnvtime('h');
console.log(prefixedHash('hello world!', new Date('2014-12-17T00:45:32.599Z')));
// hi3rz9ttj782ded88cd5a2672

License

ISC

Package Sidebar

Install

npm i fnv-time

Weekly Downloads

0

Version

0.1.0

License

ISC

Last publish

Collaborators

  • ismriv