dataprotect

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AES

type AES struct {
	// contains filtered or unexported fields
}

func NewAES

func NewAES(keyLength int) *AES

func (*AES) Decrypt

func (a *AES) Decrypt(data []byte, key []byte) ([]byte, error)

func (*AES) Encrypt

func (a *AES) Encrypt(data []byte) ([]byte, []byte, error)

type Crypto

type Crypto interface {
	Decrypt(cipher, aad, nonce []byte, kh interface{}) ([]byte, error)
	Encrypt(msg, aad []byte, kh interface{}) ([]byte, []byte, error)
}

type DataCompressor

type DataCompressor interface {
	Decompress(input []byte) ([]byte, error)
	Compress(input []byte) ([]byte, error)
}

func NewCompressor

func NewCompressor(algo string) DataCompressor

type DataProtector

type DataProtector struct {
	// contains filtered or unexported fields
}

func NewDataProtector

func NewDataProtector(
	crypto Crypto,
	cryptoKeyID string,
	dataEncryptor dataEncryptor,
	dataCompressor DataCompressor,
) *DataProtector

func (*DataProtector) Decrypt

func (d *DataProtector) Decrypt(_ context.Context, data *EncryptedData) ([]byte, error)

func (*DataProtector) Encrypt

func (d *DataProtector) Encrypt(_ context.Context, msg []byte) (*EncryptedData, error)

type EncryptedData

type EncryptedData struct {
	Encrypted      []byte `json:"encrypted"`
	EncryptedKey   []byte `json:"encrypted_key"`
	EncryptedNonce []byte `json:"encrypted_nonce"`
}

type GZip

type GZip struct {
}

func NewGzip

func NewGzip() *GZip

func (*GZip) Compress

func (g *GZip) Compress(input []byte) ([]byte, error)

Compress takes a byte slice and returns a gzip compressed byte slice.

func (*GZip) Decompress

func (g *GZip) Decompress(input []byte) ([]byte, error)

Decompress takes a gzip compressed byte slice and returns a decompressed byte slice.

type NilCrypto

type NilCrypto struct {
}

func NewNilCrypto

func NewNilCrypto() *NilCrypto

func (*NilCrypto) Decrypt

func (n *NilCrypto) Decrypt(_, aad, _ []byte, _ interface{}) ([]byte, error)

func (*NilCrypto) Encrypt

func (n *NilCrypto) Encrypt(msg, _ []byte, _ interface{}) ([]byte, []byte, error)

type NilZip

type NilZip struct {
}

func NewNilZip

func NewNilZip() *NilZip

func (*NilZip) Compress

func (g *NilZip) Compress(input []byte) ([]byte, error)

func (*NilZip) Decompress

func (g *NilZip) Decompress(input []byte) ([]byte, error)

type ZStd

type ZStd struct {
}

func NewZStd

func NewZStd() *ZStd

func (*ZStd) Compress

func (g *ZStd) Compress(input []byte) ([]byte, error)

func (*ZStd) Decompress

func (g *ZStd) Decompress(input []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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