f
This commit is contained in:
@@ -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 == "" {
|
||||
|
||||
Reference in New Issue
Block a user