代码拉取完成,页面将自动刷新
package dongle
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
var sm3Tests = []struct {
input string
toHex string
toBase64 string
}{
{"", "", ""},
{"hello world", "44f0061e69fa6fdfc290c494654a05dc0c053da7e5c52b84ef93a9d67d3fff88", "RPAGHmn6b9/CkMSUZUoF3AwFPaflxSuE75Op1n0//4g="},
}
func TestSm3_Encrypt_String(t *testing.T) {
for index, test := range sm3Tests {
e := Encrypt.FromString(test.input).BySm3()
t.Run(fmt.Sprintf("test_%d", index), func(t *testing.T) {
assert.Nil(t, e.Error)
assert.Equal(t, test.toHex, e.ToHexString())
assert.Equal(t, test.toBase64, e.ToBase64String())
})
}
}
func TestSm3_Encrypt_Bytes(t *testing.T) {
for index, test := range sm3Tests {
e := Encrypt.FromBytes([]byte(test.input)).BySm3()
t.Run(fmt.Sprintf("test_%d", index), func(t *testing.T) {
assert.Nil(t, e.Error)
assert.Equal(t, []byte(test.toHex), e.ToHexBytes())
assert.Equal(t, []byte(test.toBase64), e.ToBase64Bytes())
})
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。