HMACSHA256
Overview
HMACSHA256 returns HMAC-SHA256 of data with key as lowercase hex.
If you are coming from Node.js, the closest pattern is crypto.createHmac('sha256', key).update(d).digest('hex').
Signature
go
func HMACSHA256(data, key []byte) stringCompare: Node.js · Standard Go · gox
js
crypto.createHmac('sha256', key).update(d).digest('hex')go
h := sha256.Sum256(data)
// or hmac.New(sha256.New, key)go
import "github.com/sahilkhaire/gox/crypto"
crypto.HMACSHA256(d, key)Example
go
import "github.com/sahilkhaire/gox/crypto"
crypto.HMACSHA256(d, key)Tips
Import github.com/sahilkhaire/gox/crypto and call HMACSHA256 directly. See the comparison below for the standard library equivalent.
Standard library alternative
Use the standard library directly:
go
h := sha256.Sum256(data)
// or hmac.New(sha256.New, key)