
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
sodium-hmac
Advanced tools
HMAC utility
const { HMAC, sha256 } = require('sodium-hmac')
const hmac = new HMAC(sha256)
hmac.init(Buffer.from('key'))
.update(Buffer.from('some'))
.update(Buffer.from('more'))
.update(Buffer.from('data'))
const output = hmac.final()
// or use simple api
const same = HMAC.sha256(b4a.from('somemoredata'), key)
const hmac = new HMAC(hash, [key])Returns a HMAC object using the given hash function. If key is provided, init will be called in the constructror
Expects hash to be an object with:
initupdatefinalBYTESSTATEBYTESsha256 and sha512 are exported by default.
Returned API:
initupdatefinalsimpleBYTESSTATEBYTESExample usage:
const blake2b = {
init: sodium.crypto_generichash_init,
update: sodium.crypto_generichash_update,
final: sodium.crypto_generichash_final,
BYTES: sodium.crypto_generichash_BYTES,
STATEBYTES: sodium.crypto_generichash_STATEBYTES
}
const hmac = new HMAC(blake2b)
hmac.update(data)Hash data into the HMAC. hmac.init() must be called prior to updating
const output = hmac.update([buffer])Finlise the HMAC. The result will be written to buffer if present
const result = HMAC.sha256(data, key, [output])Produce an HMAC-SHA256 over data with key
const result = HMAC.sha512(data, key, [output])Produce an HMAC-SHA512 over data with key
Exports an HMAC-compatible SHA256 API.
Exports an HMAC-compatible SHA512 API.
Apache-2.0
FAQs
HMAC utility
We found that sodium-hmac demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.