mirror of
https://github.com/skyle1995/NetworkAuth.git
synced 2026-05-25 10:42:45 +08:00
Add classification annotations
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user