fix cleanQueryData

This commit is contained in:
2025-04-08 21:53:45 +08:00
parent ebdf38e1da
commit 91db6239d9
3 changed files with 57 additions and 7 deletions

View File

@@ -12,14 +12,15 @@ func TestAesEcbMobileEncryption(t *testing.T) {
mobile := "13800138000"
key := []byte("1234567890abcdef") // 16字节AES-128密钥
keyStr := hex.EncodeToString(key)
// 测试加密
encrypted, err := EncryptMobile(mobile, key)
encrypted, err := EncryptMobile(mobile, keyStr)
if err != nil {
t.Fatalf("手机号加密失败: %v", err)
}
fmt.Println(encrypted)
// 测试解密
decrypted, err := DecryptMobile(encrypted, key)
decrypted, err := DecryptMobile(encrypted, keyStr)
if err != nil {
t.Fatalf("手机号解密失败: %v", err)
}
@@ -30,7 +31,7 @@ func TestAesEcbMobileEncryption(t *testing.T) {
}
// 测试相同输入产生相同输出(确定性)
encrypted2, _ := EncryptMobile(mobile, key)
encrypted2, _ := EncryptMobile(mobile, keyStr)
if encrypted != encrypted2 {
t.Errorf("AES-ECB不是确定性的两次加密结果不同: %s vs %s", encrypted, encrypted2)
}