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