Documentation ¶
Index ¶
Constants ¶
View Source
const SecureField = "__encrypted__"
SecureField - encryption prefix for mongo and mysql
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EncProvider ¶
type EncProvider interface { Init() error Keys() (res string) CurrentVersion() string CurrentVersionInt() int CurrentKey() string GetKeyVersion(v int) string Len() int SwitchNextVersion(version int) error Version() int Provider() string Type() string KeyId() string Encrypt(keyVersion int, data []byte) (cryptData []byte, err error) EncryptMany(keyVersion int, data ...[]byte) (cryptData [][]byte, err error) Decrypt(keyVersion int, data []byte) (rawData []byte, err error) DecryptMany(keyVersion int, data ...[]byte) (rawData [][]byte, err error) }
EncProvider - interfaces for encryption library or encryption as a services
type Encryption ¶
type Encryption interface { MongoEncrypt(data interface{}) (res interface{}, err error) MongoDecrypt(data interface{}, dest interface{}) (err error) SqlScheme(data interface{}) (val interface{}, name string, err error) SqlEncrypt(data interface{}) (val interface{}, err error) SqlDecrypt(src, dst interface{}) (err error) DefaultProvider() EncProvider Provider(providerId, keyId string) EncProvider CreateSqlMeta(provider EncProvider) SqlEncMeta CreateMeta(provider EncProvider) Meta GetKeyId(keyId string) string GetKeyVersion(keyId string) (version int) Hash(data []byte) []byte }
type KeyProviderConfig ¶
type KeyProviderConfig struct { // KeyProvider - provider id, cons Provider Provider KeyProvider `validate:"required"` // Default - use for default new encryption Default bool // Env - env key secret name Env string }
KeyProviderConfig - provider config
type Meta ¶
type Meta struct { Version int `json:"version" bson:"version"` Provider string `json:"provider" bson:"provider"` Type string `json:"type" bson:"type"` Id string `json:"id" bson:"id"` KeyVersion int `json:"-" bson:"-" ignored:"true"` }
Meta - for encryption meta, sql or mongo
type Provider ¶
type Provider interface { DefaultProvider() EncProvider CreateSqlMeta(provider EncProvider) SqlEncMeta CreateMeta(provider EncProvider) Meta Provider(providerId, keyId string) EncProvider Hash(data []byte) []byte }
Click to show internal directories.
Click to hide internal directories.