encryption

package
v1.0.1000 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2023 License: MIT Imports: 0 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 KeyProvider

type KeyProvider int
const (
	ProviderEnv KeyProvider = iota + 1
)

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
}

type SqlEncMeta

type SqlEncMeta struct {
	Version    int    `json:"version"`
	Provider   string `json:"provider"`
	Type       string `json:"type"`
	Id         string `json:"id"`
	KeyVersion int    `json:"-"`
}

SqlEncMeta - for sql encryption meta

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL