hash-util
A hash helper, including md5, sha1, sha256, sha512, sortable-hash and geohash.
Install
npm install hash-util
API
Node.js crypto hash wrapper. Default encoding is 'hex'.
- hash.md5(str, [encoding])
- hash.sha1(str, [encoding])
- hash.sha256(str, [encoding])
- hash.sha512(str, [encoding])
Sortable-hash wrapper.
- hash.sortable.encode(values[, options])
- hash.sortable.decode(string, numValues)
- hash.geo.encode(coordinate, precision) // coordinate => { lng: 116.389550, lat: 39.928167 }
- hash.geo.decode(string)
Usage
var hash = ; var str = 'abcdefg.....'; console;console;console;console; console;console;console;console; var sh = hashsortable;console; // => skfsmq4xj7d9console; // => [ 9.999942779541016, 9.999942779541016, -9.999942779541016 ] var biggerHash = hashsortable;console; // => skfsmq4xj7d9v2fsmq4xj7d9v2fsmq4xj3hconsole; // => [ 10, 10, -10 ] var corrd = lng: 116389550 lat: 39928167 gh = hashgeo;console; // => wx4g0s8qconsole; // => { lng: 116.38967514038086, lat: 39.928178787231445 }