代码拉取完成,页面将自动刷新
同步操作将从 dromara/dongle 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package dongle
import (
"github.com/stretchr/testify/assert"
"strconv"
"testing"
)
var rc4Test = []struct {
input string
key string
toHex string
toBase64 string
}{
{"", "", "", ""},
{"hello world", "dongle", "eba154b4cb5a9038dbbf9d", "66FUtMtakDjbv50="},
}
func TestEncrypt_ByRc4_ToString(t *testing.T) {
for index, test := range rc4Test {
e := Encrypt.FromString(test.input).ByRc4(test.key)
assert.Nil(t, e.Error)
assert.Equal(t, test.toHex, e.ToHexString(), "Hex test index is "+strconv.Itoa(index))
assert.Equal(t, test.toBase64, e.ToBase64String(), "Base64 test index is "+strconv.Itoa(index))
}
}
func TestEncrypt_ByRc4_ToBytes(t *testing.T) {
for index, test := range rc4Test {
e := Encrypt.FromBytes([]byte(test.input)).ByRc4([]byte(test.key))
assert.Nil(t, e.Error)
assert.Equal(t, []byte(test.toHex), e.ToHexBytes(), "Hex test test index is "+strconv.Itoa(index))
assert.Equal(t, []byte(test.toBase64), e.ToBase64Bytes(), "Base64 test index is "+strconv.Itoa(index))
}
}
func TestRc4_Ciphertext_Error(t *testing.T) {
e1 := Encrypt.FromString("hello world").ByRc4("")
assert.Equal(t, invalidRc4KeyError(0), e1.Error, "Should catch an exception")
e2 := Encrypt.FromBytes([]byte("hello world")).ByRc4([]byte(""))
assert.Equal(t, invalidRc4KeyError(0), e2.Error, "Should catch an exception")
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。