Documentation
¶
Overview ¶
================ Version : V1.0.0 ===========
================ Version : V1.0.0 ===========
Index ¶
- Variables
- func Init(key []byte) error
- func IsInitialized() bool
- type BunModel
- type Service
- func (s *Service) Decrypt(ciphertext string) (string, error)
- func (s *Service) DecryptBytes(ciphertext []byte) ([]byte, error)
- func (s *Service) DecryptFields(v interface{}, fieldNames ...string) error
- func (s *Service) DecryptModel(v interface{}) error
- func (s *Service) DecryptStruct(v interface{}) error
- func (s *Service) Encrypt(plaintext string) (string, error)
- func (s *Service) EncryptBytes(plaintext []byte) ([]byte, error)
- func (s *Service) EncryptFields(v interface{}, fieldNames ...string) error
- func (s *Service) EncryptModel(v interface{}) error
- func (s *Service) EncryptStruct(v interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingKey = errors.New("encryption key is missing") ErrInvalidKeyLength = errors.New("key must be 16, 24, or 32 bytes") ErrEncryptionFailed = errors.New("encryption failed") ErrDecryptionFailed = errors.New("decryption failed") ErrInvalidData = errors.New("invalid encrypted data") )
Functions ¶
func Init ¶ added in v1.0.10
Init must be called once at application startup
Types ¶
type BunModel ¶ added in v1.0.10
type BunModel struct{}
func (*BunModel) AfterSelect ¶ added in v1.0.10
func (*BunModel) BeforeInsert ¶ added in v1.0.10
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func Default ¶ added in v1.0.10
func Default() *Service
Default returns the global service — panics early with a clear message if not initialized
func NewService ¶
NewService creates a new encryption service
func (*Service) Decrypt ¶
Decrypt decrypts base64 encoded ciphertext
func (*Service) DecryptBytes ¶
DecryptBytes decrypts byte slice
func (*Service) DecryptFields ¶
DecryptFields decrypts specific fields by name
func (*Service) DecryptModel ¶ added in v1.0.10
DecryptModel walks a struct / slice / pointer model and decrypts each struct element.
func (*Service) DecryptStruct ¶
DecryptStruct decrypts all fields with `encrypt:"true"` tag
func (*Service) Encrypt ¶
Encrypt encrypts plaintext and returns base64 encoded string
func (*Service) EncryptBytes ¶
EncryptBytes encrypts byte slice
func (*Service) EncryptFields ¶
EncryptFields encrypts specific fields by name
func (*Service) EncryptModel ¶ added in v1.0.10
EncryptModel walks a struct / slice / pointer model and encrypts each struct element.
Source Files
¶
- encrypt_func.go
- encrypt_tags.go
- global.go
- hooks.go