This commit is contained in:
Mrx
2026-05-09 12:15:25 +08:00
parent 7aa4fb60f6
commit 93886e2e90
11 changed files with 413 additions and 40 deletions

View File

@@ -214,6 +214,18 @@ func EncryptIDCard(idCard string, key []byte) (string, error) {
return AesEcbEncrypt([]byte(idCard), key)
}
// EncryptDeterministicOptional 对非空明文做 AES-ECB 确定性加密;空串表示不建索引列,返回 ok=false
func EncryptDeterministicOptional(plain string, key []byte) (cipher string, ok bool, err error) {
if plain == "" {
return "", false, nil
}
cipher, err = AesEcbEncrypt([]byte(plain), key)
if err != nil {
return "", false, err
}
return cipher, true, nil
}
// DecryptIDCard 解密身份证号
func DecryptIDCard(encryptedIDCard string, key []byte) (string, error) {
if encryptedIDCard == "" {