github.com/lingyao2333/mo-zero@v1.4.1/core/codec/hmac_test.go (about)

     1  package codec
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestHmac(t *testing.T) {
    11  	ret := Hmac([]byte("foo"), "bar")
    12  	assert.Equal(t, "f9320baf0249169e73850cd6156ded0106e2bb6ad8cab01b7bbbebe6d1065317",
    13  		fmt.Sprintf("%x", ret))
    14  }
    15  
    16  func TestHmacBase64(t *testing.T) {
    17  	ret := HmacBase64([]byte("foo"), "bar")
    18  	assert.Equal(t, "+TILrwJJFp5zhQzWFW3tAQbiu2rYyrAbe7vr5tEGUxc=", ret)
    19  }