AES 字段加密迁配置并兼容旧密文

移除字段加密硬编码主密钥,改为 FIELD_ENCRYPTION_KEY 注入。

保留 FIELD_ENCRYPTION_LEGACY_KEY 透明回退旧密文,新写入统一使用主密钥;生产环境校验主密钥和 legacy 密钥长度、占位符及相等关系,并统一生产环境判断口径。

补充配置与旧密文兼容回归测试。
This commit is contained in:
yml
2026-06-14 17:53:24 +08:00
parent 64f7ed3753
commit 8fef037be3
15 changed files with 519 additions and 82 deletions
@@ -5,7 +5,6 @@ import (
"encoding/json"
"hfb_sys/backend/internal/model"
"hfb_sys/backend/pkg/crypto"
)
// 转换为用户DTO
@@ -64,7 +63,7 @@ func (r *Repository) toDetailDTO(ctx context.Context, w model.WithdrawalRequest)
var paymentAccount model.UserPaymentAccount
if err := db.First(&paymentAccount, *w.PaymentAccountID).Error; err == nil {
// 解密账号
decrypted, err := crypto.Decrypt(paymentAccount.AccountNo)
decrypted, err := r.encryptor.Decrypt(paymentAccount.AccountNo)
if err == nil {
fullAccountNo = decrypted
}