canonical-tent-json
Version:
Generate canonical JSON for Tent 0.3 posts
11 lines (10 loc) • 349 B
JavaScript
module.exports = function(thing){
if (!thing) thing = this;
var crypto = require('crypto');
var data;
if (typeof thing === 'string') data = thing;
if (typeof thing === 'object') data = JSON.stringify(thing);
var shasum = crypto.createHash('sha512');
shasum.update(data);
return 'sha512t256-' + shasum.digest('hex').substr(0, 64);
};