hmac_test.go 412 B

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