dataprotect

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 2 modules, 1 package

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

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