crypto

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crypt

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

Crypt type represents the crypt abstraction for simple encryption and decryption. A provider (e.g. AWS KMS) determines the detail of the cryptographic operations.

func New added in v0.0.4

func New(kms KMS) *Crypt

New creates a new Crypt with the given provider

func (*Crypt) Decrypt added in v0.0.4

func (c *Crypt) Decrypt(input []byte) ([]byte, error)

Decrypt decrypts given bytes using the current provider

func (*Crypt) DecryptFile

func (c *Crypt) DecryptFile(inputPath, outputPath string) error

DecryptFile reads from the inputPath file or stdin if empty. Then decrypts content with corresponding Key Management Service. Plaintext is saved into outputPath file or print on stdout if empty.

func (*Crypt) Encrypt added in v0.0.4

func (c *Crypt) Encrypt(input []byte) ([]byte, error)

Encrypt encrypts given bytes using the current provider

func (*Crypt) EncryptFile

func (c *Crypt) EncryptFile(inputPath, outputPath string) error

EncryptFile encrypts bytes from a file or stdin using a KMS provider and the ciphertext is saved into a file. If inputPath is empty, stdin is used as input If outputPath is empty, stdout is used as output

type KMS

type KMS interface {
	Encrypt(plaintext []byte) ([]byte, error)
	Decrypt(ciphertext []byte) ([]byte, error)
}

KMS (Key Management Service) is a common abstraction for encryption and decryption. A KMS must be able to decrypt the data it encrypts.

Jump to

Keyboard shortcuts

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