清空,重构

This commit is contained in:
2026-04-28 13:15:55 +08:00
parent 381079bbf3
commit 61535a53c2
170 changed files with 0 additions and 1219 deletions

View File

@@ -1,35 +0,0 @@
import base64
import hashlib
from cryptography.fernet import Fernet
from django.conf import settings
class PhoneEncryption:
"""
手机号 AES-256-GCM 加密存储 + SHA-256 哈希索引
存储字段phone_encrypted加密密文+ phone_hash哈希用于精确查询
显示:脱敏格式 138****1234
"""
@staticmethod
def encrypt(phone: str) -> str:
"""加密手机号,返回 base64 密文"""
...
@staticmethod
def decrypt(ciphertext: str) -> str:
"""解密返回明文"""
...
@staticmethod
def hash(phone: str) -> str:
"""返回 SHA-256 哈希(用于 DB 索引查询)"""
...
@staticmethod
def mask(phone: str) -> str:
"""返回脱敏格式138****1234"""
if not phone or len(phone) < 7:
return "***"
return phone[:3] + "****" + phone[-4:]