fix
This commit is contained in:
@@ -60,7 +60,7 @@ AdminConfig:
|
||||
AccessExpire: 604800
|
||||
RefreshAfter: 302400
|
||||
Tianyuanapi:
|
||||
AccessID: "3c042bb99b240ccc"
|
||||
Key: "2732f526167c2de9b8dc6aa0f24ba8b7"
|
||||
AccessID: "7f8a9b2c4d5e6f1a"
|
||||
Key: "9e4f8a1b3c6d7e2f5a8b9c0d1e4f7a2b"
|
||||
BaseURL: "https://api.tianyuanapi.com"
|
||||
Timeout: 60
|
||||
@@ -61,7 +61,7 @@ AdminConfig:
|
||||
AccessExpire: 604800
|
||||
RefreshAfter: 302400
|
||||
Tianyuanapi:
|
||||
AccessID: "3c042bb99b240ccc"
|
||||
Key: "2732f526167c2de9b8dc6aa0f24ba8b7"
|
||||
AccessID: "7f8a9b2c4d5e6f1a"
|
||||
Key: "9e4f8a1b3c6d7e2f5a8b9c0d1e4f7a2b"
|
||||
BaseURL: "https://api.tianyuanapi.com"
|
||||
Timeout: 60
|
||||
@@ -72,23 +72,11 @@ func (l *PaySuccessNotifyUserHandler) ProcessTask(ctx context.Context, t *asynq.
|
||||
return fmt.Errorf("解密参数失败: %+v", aesdecryptErr)
|
||||
}
|
||||
|
||||
// 敏感数据脱敏处理
|
||||
desensitizedParams, err := l.desensitizeParams(decryptData)
|
||||
if err != nil {
|
||||
return fmt.Errorf("脱敏处理失败: %+v", err)
|
||||
}
|
||||
|
||||
// 对脱敏后的数据进行AES加密
|
||||
encryptedParams, encryptErr := crypto.AesEncrypt(desensitizedParams, key)
|
||||
if encryptErr != nil {
|
||||
return fmt.Errorf("加密脱敏数据失败: %+v", encryptErr)
|
||||
}
|
||||
|
||||
query := &model.Query{
|
||||
OrderId: order.Id,
|
||||
UserId: order.UserId,
|
||||
ProductId: product.Id,
|
||||
QueryParams: encryptedParams,
|
||||
QueryParams: data.Params,
|
||||
QueryState: "pending",
|
||||
}
|
||||
result, insertQueryErr := l.svcCtx.QueryModel.Insert(ctx, nil, query)
|
||||
|
||||
@@ -9,19 +9,18 @@ import (
|
||||
|
||||
func TestAesEcbMobileEncryption(t *testing.T) {
|
||||
// 测试手机号加密
|
||||
mobile := "18653052547"
|
||||
key := []byte("ff83609b2b24fc73196aac3d3dfb874f") // 16字节AES-128密钥
|
||||
mobile := "18276151590"
|
||||
key := "ff83609b2b24fc73196aac3d3dfb874f" // 16字节AES-128密钥
|
||||
|
||||
keyStr := hex.EncodeToString(key)
|
||||
// 测试加密
|
||||
encrypted, err := EncryptMobile(mobile, keyStr)
|
||||
encrypted, err := EncryptMobile(mobile, key)
|
||||
if err != nil {
|
||||
t.Fatalf("手机号加密失败: %v", err)
|
||||
}
|
||||
fmt.Printf("encrypted: %s\n", encrypted)
|
||||
jmStr := "m9EEeW9ZBBJmi1hx1k1uIQ=="
|
||||
// 测试解密
|
||||
decrypted, err := DecryptMobile(jmStr, keyStr)
|
||||
decrypted, err := DecryptMobile(jmStr, key)
|
||||
if err != nil {
|
||||
t.Fatalf("手机号解密失败: %v", err)
|
||||
}
|
||||
@@ -32,7 +31,7 @@ func TestAesEcbMobileEncryption(t *testing.T) {
|
||||
}
|
||||
|
||||
// 测试相同输入产生相同输出(确定性)
|
||||
encrypted2, _ := EncryptMobile(mobile, keyStr)
|
||||
encrypted2, _ := EncryptMobile(mobile, key)
|
||||
if encrypted != encrypted2 {
|
||||
t.Errorf("AES-ECB不是确定性的,两次加密结果不同: %s vs %s", encrypted, encrypted2)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user