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

@@ -7,6 +7,10 @@ import (
"fmt"
)
// ============================================================================
// 公共函数
// ============================================================================
// GenerateSecureJWTSecret 生成安全的JWT密钥
// 生成64字节512位的随机密钥使用base64编码
func GenerateSecureJWTSecret() (string, error) {
@@ -15,7 +19,7 @@ func GenerateSecureJWTSecret() (string, error) {
if _, err := rand.Read(bytes); err != nil {
return "", fmt.Errorf("生成JWT密钥失败: %w", err)
}
// 使用base64编码便于配置文件存储
return base64.StdEncoding.EncodeToString(bytes), nil
}
@@ -28,7 +32,7 @@ func GenerateSecureEncryptionKey() (string, error) {
if _, err := rand.Read(bytes); err != nil {
return "", fmt.Errorf("生成加密密钥失败: %w", err)
}
// 使用十六进制编码
return hex.EncodeToString(bytes), nil
}
@@ -39,11 +43,11 @@ func GenerateSecureKeys() (jwtSecret, encryptionKey string, err error) {
if err != nil {
return "", "", err
}
encryptionKey, err = GenerateSecureEncryptionKey()
if err != nil {
return "", "", err
}
return jwtSecret, encryptionKey, nil
}
}