How to use the sodium-native.crypto_hash_sha256 function in sodium-native

To help you get started, we’ve selected a few sodium-native 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 blockades / dark-crystal-secrets / v2.js View on Github external
function Mac (secret) {
  var hash = Buffer.alloc(sodium.crypto_hash_sha256_BYTES)
  sodium.crypto_hash_sha256(hash, Buffer.from(secret))

  return hash
    .toString('hex')
    .slice(-1 * MAC_LENGTH)
}
github blockades / scuttle-dark-crystal / lib / secrets-wrapper / v2.js View on Github external
function Mac (secret) {
  var hash = Buffer.alloc(sodium.crypto_hash_sha256_BYTES)
  sodium.crypto_hash_sha256(hash, Buffer.from(secret))

  return hash
    .toString('hex')
    .slice(-1 * MAC_LENGTH)
}
github holochain / n3h / lib / mosodium / hash.js View on Github external
exports.sha256 = function hashSha256 (input) {
  if (!(input instanceof Buffer)) {
    throw new Error('input must be a Buffer')
  }
  const output = Buffer.alloc(sodium.crypto_hash_sha256_BYTES)
  sodium.crypto_hash_sha256(output, input)
  return output
}