crypto

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(key, encrypted []byte) ([]byte, error)

Decrypt performs AES-256 GCM decryption with a given 32-bytes key.

func DecryptWithRSA added in v0.3.0

func DecryptWithRSA(encrypted, privKey, password []byte) ([]byte, error)

DecryptWithRSA decrypts the given encrypted data with RSA-OAEP. privKey must be a RSA private key in PEM or DER format.

func DeriveKey added in v0.3.0

func DeriveKey(password string, salt []byte) []byte

func Encrypt

func Encrypt(key, plaintext []byte) ([]byte, error)

Encrypt performs AES-256 GCM encryption with a given 32-bytes key.

func EncryptWithRSA added in v0.3.0

func EncryptWithRSA(plaintext, pubKey []byte) ([]byte, error)

EncryptWithRSA encrypts the given data with RSA-OAEP. pubKey must be a RSA public key in PEM or DER format.

Types

type GPG added in v0.3.0

type GPG interface {
	// EncryptWithRecipient encrypts a given plaintext using a given user's public-key.
	EncryptWithRecipient(ctx context.Context, plaintext []byte, userID string) ([]byte, error)
	// DecryptWithRecipient decrypts a given encrypted data using a given user's private-key.
	DecryptWithRecipient(ctx context.Context, encrypted []byte, userID string) ([]byte, error)
}

GPG works as a GPG client.

func NewGPG added in v0.3.0

func NewGPG(executable string) GPG

Jump to

Keyboard shortcuts

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