Documentation
¶
Index ¶
- func DecryptValue(encryptedValue string, config *EncryptionConfig) (string, error)
- func EncryptData(data interface{}, config *EncryptionConfig) (string, error)
- func EncryptValue(value string, config *EncryptionConfig) (string, error)
- type AESEncryptor
- type DBError
- type DataProcessor
- type DefaultMasker
- type EncryptionAlgorithm
- type EncryptionConfig
- type Encryptor
- type ErrorCode
- type FieldSecurity
- type KeyRotationConfig
- type KeyRotationInfo
- type Masker
- type SecurityManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptValue ¶ added in v4.2.5
func DecryptValue(encryptedValue string, config *EncryptionConfig) (string, error)
DecryptValue enhances decryption with ChaCha20-Poly1305 support
func EncryptData ¶ added in v4.5.0
func EncryptData(data interface{}, config *EncryptionConfig) (string, error)
func EncryptValue ¶ added in v4.2.5
func EncryptValue(value string, config *EncryptionConfig) (string, error)
EncryptValue 使用指定的配置加密值
Types ¶
type AESEncryptor ¶
type AESEncryptor struct {
// contains filtered or unexported fields
}
AESEncryptor 提供AES加密实现
func NewAESEncryptor ¶
func NewAESEncryptor(key []byte) (*AESEncryptor, error)
NewAESEncryptor 创建AES加密器
type DataProcessor ¶
type DataProcessor struct {
// contains filtered or unexported fields
}
DataProcessor 数据处理器
func NewDataProcessor ¶
func NewDataProcessor(key []byte) (*DataProcessor, error)
NewDataProcessor 创建数据处理器
func (*DataProcessor) ConfigureField ¶
func (dp *DataProcessor) ConfigureField(field string, config FieldSecurity)
ConfigureField 配置字段安全规则
func (*DataProcessor) ProcessData ¶
func (dp *DataProcessor) ProcessData(data map[string]interface{}) error
ProcessData 处理数据
func (*DataProcessor) UnprocessData ¶
func (dp *DataProcessor) UnprocessData(data map[string]interface{}) error
UnprocessData 还原数据
type DefaultMasker ¶
type DefaultMasker struct {
// contains filtered or unexported fields
}
DefaultMasker 提供默认的脱敏实现
type EncryptionAlgorithm ¶ added in v4.2.5
type EncryptionAlgorithm string
EncryptionAlgorithm defines the encryption algorithm to use
const ( // AES256 uses AES-256 encryption AES256 EncryptionAlgorithm = "AES256" // AES192 uses AES-192 encryption AES192 EncryptionAlgorithm = "AES192" // AES128 uses AES-128 encryption AES128 EncryptionAlgorithm = "AES128" // ChaCha20Poly1305 uses ChaCha20-Poly1305 encryption ChaCha20Poly1305 EncryptionAlgorithm = "ChaCha20Poly1305" )
type EncryptionConfig ¶ added in v4.2.5
type EncryptionConfig struct {
Algorithm EncryptionAlgorithm
KeySource string
KeySourceConfig map[string]string
}
EncryptionConfig represents configuration for encryption operations
type Encryptor ¶
type Encryptor interface {
Encrypt(value string) (string, error)
Decrypt(value string) (string, error)
}
Encryptor 定义了数据加密接口
type ErrorCode ¶ added in v4.2.5
type ErrorCode string
ErrorCode represents error codes for security operations
type FieldSecurity ¶
FieldSecurity 字段安全配置
type KeyRotationConfig ¶ added in v4.2.5
KeyRotationConfig defines the configuration for key rotation
type KeyRotationInfo ¶ added in v4.2.5
KeyRotationInfo stores information about key rotation
type SecurityManager ¶
type SecurityManager struct {
// contains filtered or unexported fields
}
SecurityManager 安全管理器,集成脱敏和加密功能
func NewSecurityManager ¶
func NewSecurityManager(key []byte) (*SecurityManager, error)
NewSecurityManager 创建安全管理器
func (*SecurityManager) DecryptData ¶
func (sm *SecurityManager) DecryptData(value string) (string, error)
DecryptData 解密数据
func (*SecurityManager) EncryptData ¶
func (sm *SecurityManager) EncryptData(value string) (string, error)
EncryptData 加密数据
func (*SecurityManager) MaskData ¶
func (sm *SecurityManager) MaskData(value string, ruleType string) string
MaskData 脱敏数据
func (*SecurityManager) RotateKey ¶ added in v4.2.5
func (sm *SecurityManager) RotateKey() error
RotateKey performs key rotation based on the configured schedule