Add classification annotations

This commit is contained in:
2025-10-27 23:12:15 +08:00
parent 3990ec01c6
commit 5aacb88c22
44 changed files with 2769 additions and 2241 deletions

View File

@@ -15,6 +15,10 @@ import (
"golang.org/x/crypto/bcrypt"
)
// ============================================================================
// 结构体定义
// ============================================================================
// CryptoManager 加密管理器,提供高性能的加密解密服务
type CryptoManager struct {
key []byte
@@ -23,9 +27,17 @@ type CryptoManager struct {
inited bool
}
// ============================================================================
// 全局变量
// ============================================================================
// 全局加密管理器实例
var cryptoManager = &CryptoManager{}
// ============================================================================
// 私有函数
// ============================================================================
// initCrypto 初始化加密管理器
// 缓存密钥和GCM实例避免重复创建
func (cm *CryptoManager) initCrypto() error {
@@ -63,6 +75,10 @@ func (cm *CryptoManager) initCrypto() error {
return nil
}
// ============================================================================
// 加密解密函数
// ============================================================================
// EncryptString 字符串加密AES-256-GCM
// 使用缓存的密钥和GCM实例提高性能
func EncryptString(plain string) (string, error) {