Initialize Fonrey Django multi-tenant project skeleton

Set up the required directory layout, app scaffolding, core settings, templates, static assets, and Docker/Tailwind tooling to establish a standardized development baseline.
This commit is contained in:
2026-04-26 17:12:09 +08:00
commit 4aba6dfa77
170 changed files with 1220 additions and 0 deletions

35
core/encryption.py Normal file
View File

@@ -0,0 +1,35 @@
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:]