dataprotect

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 12 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 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(
	keyEncryptor encDec,
	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 NilDataProtector added in v1.6.0

type NilDataProtector struct {
}

func NewNilDataProtector added in v1.6.0

func NewNilDataProtector() *NilDataProtector

func (*NilDataProtector) Decrypt added in v1.6.0

func (n *NilDataProtector) Decrypt(_ context.Context, encryptedData *EncryptedData) ([]byte, error)

func (*NilDataProtector) Encrypt added in v1.6.0

func (n *NilDataProtector) Encrypt(_ context.Context, msg []byte) (*EncryptedData, 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 Protector added in v1.6.0

type Protector interface {
	Encrypt(ctx context.Context, msg []byte) (*EncryptedData, error)
	Decrypt(ctx context.Context, encryptedData *EncryptedData) ([]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