Skip to content
Node: crypto, bcrypt6 APIs

crypto

Package crypto provides Node crypto-style hashing, HMAC, random bytes, and bcrypt passwords. Node equivalent: crypto.createHash, crypto.randomBytes, bcrypt.

import "github.com/sahilkhaire/gox/crypto"
## API reference

Select a symbol below — each page explains what it does, shows Node.js vs Go comparisons, and includes a runnable example.

Functions

SymbolNode.jsKindSummary
CheckPasswordbcrypt.compare(password, hash)funcCheckPassword reports whether password matches the bcrypt hash.
HMACSHA256crypto.createHmac('sha256', key).update(d).digest('hex')funcHMACSHA256 returns HMAC-SHA256 of data with key as lowercase hex.
HashPasswordbcrypt.hash(password, 10)funcHashPassword hashes password with bcrypt (bcrypt.hash).
RandomBytescrypto.randomBytes(n)funcRandomBytes returns n cryptographically secure random bytes (crypto.randomBytes).
RandomStringfuncRandomString returns a URL-safe base64 string with roughly n bytes of entropy (uses n random bytes, encoded without p...
SHA256crypto.createHash('sha256').update(d).digest('hex')funcSHA256 returns the SHA-256 digest of data as lowercase hex (crypto.createHash('sha256')).

MIT Licensed · Built for Node.js developers moving to Go