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"
Select a symbol below — each page explains what it does, shows Node.js vs Go comparisons, and includes a runnable example.
Functions
| Symbol | Node.js | Kind | Summary |
|---|---|---|---|
| CheckPassword | bcrypt.compare(password, hash) | func | CheckPassword reports whether password matches the bcrypt hash. |
| HMACSHA256 | crypto.createHmac('sha256', key).update(d).digest('hex') | func | HMACSHA256 returns HMAC-SHA256 of data with key as lowercase hex. |
| HashPassword | bcrypt.hash(password, 10) | func | HashPassword hashes password with bcrypt (bcrypt.hash). |
| RandomBytes | crypto.randomBytes(n) | func | RandomBytes returns n cryptographically secure random bytes (crypto.randomBytes). |
| RandomString | — | func | RandomString returns a URL-safe base64 string with roughly n bytes of entropy (uses n random bytes, encoded without p... |
| SHA256 | crypto.createHash('sha256').update(d).digest('hex') | func | SHA256 returns the SHA-256 digest of data as lowercase hex (crypto.createHash('sha256')). |