新增后台管理
This commit is contained in:
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
func TestAesEcbMobileEncryption(t *testing.T) {
|
||||
// 测试手机号加密
|
||||
mobile := "13800138000"
|
||||
key := []byte("1234567890abcdef") // 16字节AES-128密钥
|
||||
mobile := "13280082033 "
|
||||
key := []byte("ff83609b2b24fc73196aac3d3dfb874f") // 16字节AES-128密钥
|
||||
|
||||
keyStr := hex.EncodeToString(key)
|
||||
// 测试加密
|
||||
@@ -18,13 +18,14 @@ func TestAesEcbMobileEncryption(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("手机号加密失败: %v", err)
|
||||
}
|
||||
fmt.Println(encrypted)
|
||||
fmt.Printf("encrypted: %s\n", encrypted)
|
||||
jmStr := "oEpLcrIpDPN63rOlESXTDg=="
|
||||
// 测试解密
|
||||
decrypted, err := DecryptMobile(encrypted, keyStr)
|
||||
decrypted, err := DecryptMobile(jmStr, keyStr)
|
||||
if err != nil {
|
||||
t.Fatalf("手机号解密失败: %v", err)
|
||||
}
|
||||
fmt.Println(decrypted)
|
||||
fmt.Printf("decrypted: %s\n", decrypted)
|
||||
// 验证结果
|
||||
if decrypted != mobile {
|
||||
t.Errorf("解密结果不匹配,期望: %s, 实际: %s", mobile, decrypted)
|
||||
|
||||
Reference in New Issue
Block a user