Documentation
¶
Overview ¶
Package crypto 提供 AES-256-GCM 加密/解密服务
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidKeyLength 密钥长度无效(必须是32字节) ErrInvalidKeyLength = errors.New("encryption key must be 32 bytes") // ErrInvalidCiphertext 密文格式无效 ErrInvalidCiphertext = errors.New("invalid ciphertext format") // ErrDecryptionFailed 解密失败(认证失败,可能是密钥错误或密文被篡改) ErrDecryptionFailed = errors.New("decryption failed: authentication failed") )
Functions ¶
This section is empty.
Types ¶
type CryptoService ¶
type CryptoService struct {
// contains filtered or unexported fields
}
CryptoService AES-256-GCM 加密服务
func NewCryptoService ¶
func NewCryptoService(key string) (*CryptoService, error)
NewCryptoService 创建加密服务(密钥必须是32字节)
func (*CryptoService) Decrypt ¶
func (s *CryptoService) Decrypt(ciphertextBase64 string) (string, error)
Decrypt 解密 Base64 编码的密文,返回明文
Click to show internal directories.
Click to hide internal directories.