encrypt

package
v0.0.0-...-1ceb02d Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package encrypt is a wrapper around crypto/aes and crypto/rsa.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CTEq

func CTEq(c1, c2 CipherText) bool

CTEq checks ciphertexts' equality.

func GenerateKeys

func GenerateKeys() (EncryptionKey, DecryptionKey, error)

GenerateKeys creates a pair of keys for encryption/decryption

Types

type CipherText

type CipherText []byte

CipherText represents encrypted data.

type DecryptionKey

type DecryptionKey interface {
	// Decrypt decrypts ciphertext that was encrypted with corresponding encryption key.
	Decrypt(CipherText) ([]byte, error)
	// Encode encodes the decryption key.
	Encode() string
}

DecryptionKey is used for decrypting ciphertexts encrypted with corresponding encryption key.

func NewDecryptionKey

func NewDecryptionKey(text string) (DecryptionKey, error)

NewDecryptionKey creates a decryptionKey from its string representation

type EncryptionKey

type EncryptionKey interface {
	// Encrypt encrypts message.
	Encrypt([]byte) (CipherText, error)
	// Encode encodes the encryption key.
	Encode() string
}

EncryptionKey is used for encrypting messages.

func NewEncryptionKey

func NewEncryptionKey(text string) (EncryptionKey, error)

NewEncryptionKey creates encryptionKey from string representation

type SymmetricKey

type SymmetricKey interface {
	// Encrypt encrypts message.
	Encrypt([]byte) (CipherText, error)
	// Decrypt decrypts ciphertext that was encrypted with the key.
	Decrypt(CipherText) ([]byte, error)
}

SymmetricKey is used for both encrypting and decrypting messages.

func NewSymmetricKey

func NewSymmetricKey(key []byte) (SymmetricKey, error)

NewSymmetricKey creates a symmetric key for encryption/decryption.

Jump to

Keyboard shortcuts

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