encryption

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 5 Imported by: 0

README

encryption

Documentation

Index

Constants

View Source
const (
	ChaCha20Poly1305 SecretKeyEncryption = "chacha20poly1305"

	XSalsa20 PublicKeyEncryption = "xsalsa20"
)

Variables

View Source
var (
	ErrAlgorithmNotSupported = errors.New("algorithm is not supported")
	ErrNotEnoughBytes        = errors.New("not enough bytes read from crypto random source")
	ErrKeyLength             = errors.New("key has to be 32 bytes long")
)

Functions

This section is empty.

Types

type KeyGenerator added in v1.1.0

type KeyGenerator interface {
	// Generate method generates appropriate key for the implementing algorithm
	// out parameter allows the unencrypted value to be used further in the application
	Generate(out ...interface{}) error
}

func NewPublicKeyGenerator added in v1.2.0

func NewPublicKeyGenerator(algo PublicKeyEncryption, public, private io.Writer) (KeyGenerator, error)

func NewSecretKeyGenerator added in v1.2.0

func NewSecretKeyGenerator(algo SecretKeyEncryption, w io.Writer, encryptor Service) (KeyGenerator, error)

type PublicKeyEncryption added in v1.2.0

type PublicKeyEncryption string

func ValidatePublicKeyEnum added in v1.2.2

func ValidatePublicKeyEnum(value PublicKeyEncryption) (PublicKeyEncryption, error)

func (PublicKeyEncryption) MarshalJSON added in v1.2.1

func (s PublicKeyEncryption) MarshalJSON() ([]byte, error)

func (PublicKeyEncryption) MarshalYAML added in v1.2.1

func (s PublicKeyEncryption) MarshalYAML() (interface{}, error)

func (*PublicKeyEncryption) UnmarshalJSON added in v1.2.1

func (s *PublicKeyEncryption) UnmarshalJSON(bytes []byte) (err error)

func (*PublicKeyEncryption) UnmarshalYAML added in v1.2.1

func (s *PublicKeyEncryption) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

type SecretKeyEncryption added in v1.2.0

type SecretKeyEncryption string

func ValidateSecretKeyEnum added in v1.2.2

func ValidateSecretKeyEnum(value SecretKeyEncryption) (SecretKeyEncryption, error)

func (SecretKeyEncryption) MarshalJSON added in v1.2.1

func (s SecretKeyEncryption) MarshalJSON() ([]byte, error)

func (SecretKeyEncryption) MarshalYAML added in v1.2.1

func (s SecretKeyEncryption) MarshalYAML() (interface{}, error)

func (*SecretKeyEncryption) UnmarshalJSON added in v1.2.1

func (s *SecretKeyEncryption) UnmarshalJSON(bytes []byte) (err error)

func (*SecretKeyEncryption) UnmarshalYAML added in v1.2.1

func (s *SecretKeyEncryption) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

type Service

type Service interface {
	Encrypt(dst, msg []byte) ([]byte, error)
	EncryptString(msg string) ([]byte, error)
	Decrypt(dst, msg []byte) ([]byte, error)
	DecryptString(msg []byte) (string, error)
}

Service - Interface for encryption and decryption

func NewPublicKeyEncryption added in v1.2.0

func NewPublicKeyEncryption(algo PublicKeyEncryption, private, public interface{}) (Service, error)

func NewSecretKeyEncryption added in v1.2.0

func NewSecretKeyEncryption(algo SecretKeyEncryption, key interface{}) (Service, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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