mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 00:22:41 +08:00
包装签名函数
This commit is contained in:
@ -12,9 +12,12 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/charlienet/go-mixed/bytesconv"
|
||||
"github.com/charlienet/go-mixed/crypto"
|
||||
"github.com/tjfoc/gmsm/sm3"
|
||||
)
|
||||
|
||||
var _ crypto.Signer = &hashComparer{}
|
||||
|
||||
type HMacFunc func(key, msg []byte) bytesconv.BytesResult
|
||||
|
||||
var hmacFuncs = map[string]HMacFunc{
|
||||
@ -44,6 +47,11 @@ func New(fname string, key []byte) (*hashComparer, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *hashComparer) Sign(msg []byte) ([]byte, error) {
|
||||
ret := c.hashFunc(c.key, msg)
|
||||
return ret.Bytes(), nil
|
||||
}
|
||||
|
||||
func (c *hashComparer) Verify(msg, target []byte) bool {
|
||||
ret := c.hashFunc(c.key, msg)
|
||||
|
||||
|
Reference in New Issue
Block a user