This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var crypto = require('crypto'); | |
var assert = require('assert'); | |
function mcHexDigest(str) { | |
var hash = new Buffer(crypto.createHash('sha1').update(str).digest(), 'binary'); | |
// check for negative hashes | |
var negative = hash.readInt8(0) < 0; | |
if (negative) performTwosCompliment(hash); | |
var digest = hash.toString('hex'); | |
// trim leading zeroes |