encryption

package
v0.3.1 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, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgeEncryptor

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

AgeEncryptor implements the Encryptor interface using age

func (*AgeEncryptor) Encrypt

func (e *AgeEncryptor) Encrypt(in io.Reader) (io.ReadCloser, error)

Encrypt takes an io.Reader as input, which is the source of plaintext data that needs to be encrypted. It encrypts this data using the AGE encryption protocol, streaming the encrypted data to the caller through an io.ReadCloser.

Parameters: - in: An io.Reader from which the plaintext data will be read. This could be a file, a buffer, a network connection, etc.

Returns: - An io.ReadCloser through which the caller can read the encrypted data. - An error if any error occurs while setting up the encryption.

Note:

  • This function runs concurrently; it spawns a goroutine to handle the encryption process. The caller can immediately start reading from the returned io.ReadCloser, and the data will be encrypted on-the-fly as it is read.

type Encryptor

type Encryptor interface {
	// Encrypt encrypts the data from the given reader and returns an io.ReadCloser
	// that can be used to read the encrypted data. The last parameter indicates whether
	// this is the last piece of data to be encrypted. This function is expected to be called only once.
	// To resume previous encryption, use LoadState before calling Encrypt. To save the encryption state
	// for later resumption, use GetState after calling Encrypt.
	Encrypt(in io.Reader) (io.ReadCloser, error)
}

Encryptor is an interface that defines the methods required to encrypt data in a resumable way.

func GetEncryptor

func GetEncryptor(dataset model.Dataset) (Encryptor, error)

func NewAgeEncryptor

func NewAgeEncryptor(recipients []string) (Encryptor, error)

NewAgeEncryptor creates a new Encryptor instance that uses the age encryption tool to encrypt data for a specified list of recipients. Each recipient is identified by a public key string that is parsed and used to encrypt the data.

Parameters: - recipients: A list of strings, where each string is a recipient's public key.

Returns:

  • An Encryptor instance that is configured to encrypt data for the specified recipients. The Encryptor instance is assumed to conform to an interface that provides methods for encrypting data.
  • An error if any recipient's public key string fails to parse or if any other error occurs while creating the Encryptor.

Jump to

Keyboard shortcuts

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