代码拉取完成,页面将自动刷新
同步操作将从 golang-module/dongle 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package dongle
import (
"strconv"
"testing"
"github.com/stretchr/testify/assert"
)
var (
sha512Input = "hello world"
sha512HexExpected = "309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f"
sha512Base32Expected = "GCPMYSE4CLLOWTGEB5IMSAXSWTIO257OKENHY6U3ZU6KQ3KM3BXZRHOTLPC76SMWODNDIJK3IWYM7WBQ5APWAXOPPXCVILUTV2ONO3Y="
sha512Base64Expected = "MJ7MSJwS1utMxA9QyQLytNDtd+5RGnx6m808qG1M2G+YndNbxf9JlnDaNCVbRbDP2DDoH2Bdz33FVC6TrpzXbw=="
)
func TestEncrypt_BySha512_FromStringToString(t *testing.T) {
hexTests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{sha512Input, sha512HexExpected},
}
for index, test := range hexTests {
e := Encrypt.FromString(test.input).BySha512()
assert.Nil(t, e.Error)
assert.Equal(t, test.expected, e.ToHexString(), "Current test index is "+strconv.Itoa(index))
}
base32Tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{sha512Input, sha512Base32Expected},
}
for index, test := range base32Tests {
e := Encrypt.FromString(test.input).BySha512()
assert.Nil(t, e.Error)
assert.Equal(t, test.expected, e.ToBase32String(), "Current test index is "+strconv.Itoa(index))
}
base64Tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{sha512Input, sha512Base64Expected},
}
for index, test := range base64Tests {
e := Encrypt.FromString(test.input).BySha512()
assert.Nil(t, e.Error)
assert.Equal(t, test.expected, e.ToBase64String(), "Current test index is "+strconv.Itoa(index))
}
}
func TestEncrypt_BySha512_FromBytesToString(t *testing.T) {
hexTests := []struct {
input []byte // 输入值
expected string // 期望值
}{
{[]byte(""), ""},
{[]byte(sha512Input), sha512HexExpected},
}
for index, test := range hexTests {
e := Encrypt.FromBytes(test.input).BySha512()
assert.Nil(t, e.Error)
assert.Equal(t, test.expected, e.ToHexString(), "Current test index is "+strconv.Itoa(index))
}
base32Tests := []struct {
input []byte // 输入值
expected string // 期望值
}{
{[]byte(""), ""},
{[]byte(sha512Input), sha512Base32Expected},
}
for index, test := range base32Tests {
e := Encrypt.FromBytes(test.input).BySha512()
assert.Nil(t, e.Error)
assert.Equal(t, test.expected, e.ToBase32String(), "Current test index is "+strconv.Itoa(index))
}
base64Tests := []struct {
input []byte // 输入值
expected string // 期望值
}{
{[]byte(""), ""},
{[]byte(sha512Input), sha512Base64Expected},
}
for index, test := range base64Tests {
e := Encrypt.FromBytes(test.input).BySha512()
assert.Nil(t, e.Error)
assert.Equal(t, test.expected, e.ToBase64String(), "Current test index is "+strconv.Itoa(index))
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。