How to use the tweetnacl.hash function in tweetnacl

To help you get started, we’ve selected a few tweetnacl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wallix / datapeps-sdk-js / src / Tools.js View on Github external
function hmac(data) {
            return nacl.hash(Uint8Tool.concat(okeypad, nacl.hash(Uint8Tool.concat(ikeypad, data))));
        }
        // BIG endian encoding of integer i.
github bogbook / bog / ads.js View on Github external
function make (ad) {
  console.log(ad)
  
  var hex = Buffer.from(nacl.hash(nacl.util.decodeUTF8(ad))).toString('hex')
  
  var obj = {
    hash: hex,
    ad: ad,
    views: 0
  }
  
  fs.writeFile(addir + hex, JSON.stringify(obj), 'UTF-8', function () {
    console.log('Saved as ' + hex)
  })
}
github chr15m / bugout / index.js View on Github external
function sendRaw(bugout, message) {
  var wires = bugout.torrent.wires;
  for (var w=0; w
github michaellperry / jinaga / src / fact / hash.ts View on Github external
function computeObjectHash(obj: {}) {
    if (!obj)
        return '';

    const str = canonicalize(obj);
    const bytes = decodeUTF8(str);
    const result = hash(bytes);
    const b64 = encodeBase64(result);
    return b64;
}
github wallix / datapeps-sdk-js / src / Tools.ts View on Github external
function hmac(data) {
      return nacl.hash(
        Uint8Tool.concat(okeypad, nacl.hash(Uint8Tool.concat(ikeypad, data)))
      );
    }
github chr15m / bugout / index.js View on Github external
Bugout.encodeaddress = Bugout.prototype.encodeaddress = function(material) {
  return bs58check.encode(Buffer.concat([Buffer.from(ADDRESSPREFIX, "hex"), new ripemd160().update(Buffer.from(nacl.hash(material))).digest()]));
}
github michaellperry / jinaga / src / memory / debug.ts View on Github external
function shorten(value: string) {
    if (value.startsWith('"-----BEGIN RSA PUBLIC KEY-----')) {
        const bytes = decodeUTF8(value);
        const result = hash(bytes);
        const b64 = encodeBase64(result);
        return b64.substr(0, 16);
    }
    else if (value.length > 100) {
        return value.substr(0, 50) + '...' + value.substr(value.length - 47);
    }
    else {
        return value;
    }
}