Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
}
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)
}
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
}