cipher

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Ciphers = &ciphersEnum{
	Mock: "MOCK",
	Aes:  "AES",
}

Ciphers enumerates the supported Cipher types

Functions

This section is empty.

Types

type AesCipher

type AesCipher struct {
}

AesCipher implements a Cipher service with AES encryption

func (*AesCipher) Decrypt

func (c *AesCipher) Decrypt(data []byte, key []byte) ([]byte, error)

Decrypt decrypts data with a key applying AES with GCM

func (*AesCipher) Encrypt

func (c *AesCipher) Encrypt(data []byte, key []byte) ([]byte, error)

Encrypt encrypts data with a key applying AES with GCM

func (*AesCipher) PrepareKey

func (c *AesCipher) PrepareKey(key string) ([]byte, error)

PrepareKey transforms the key into AesCipher format

func (*AesCipher) Type

func (c *AesCipher) Type() Type

Type retrieves the type of AesCipher

type Cipher

type Cipher interface {
	Type() Type
	PrepareKey(key string) ([]byte, error)
	Encrypt(data []byte, key []byte) ([]byte, error)
	Decrypt(data []byte, key []byte) ([]byte, error)
	// contains filtered or unexported methods
}

Cipher is a component to interact with the different Cipher services

func NewAesCipher

func NewAesCipher() Cipher

NewAesCipher creates an instance of AesCipher

type MockCipher

type MockCipher struct {
	mock.Mock
}

MockCipher mocks a Cipher service

func NewMockCipher

func NewMockCipher() *MockCipher

NewMockCipher creates an instance of MockCipher

func (*MockCipher) Decrypt

func (m *MockCipher) Decrypt(data []byte, key []byte) ([]byte, error)

Decrypt mocks Decrypt function

func (*MockCipher) Encrypt

func (m *MockCipher) Encrypt(data []byte, key []byte) ([]byte, error)

Encrypt mocks Encrypt function

func (*MockCipher) PrepareKey

func (m *MockCipher) PrepareKey(key string) ([]byte, error)

PrepareKey mocks PrepareKey function

func (*MockCipher) Type

func (m *MockCipher) Type() Type

Type mocks Type function

type Store

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

Store maintains Ciphers with it's dependencies

func NewStore

func NewStore() (*Store, error)

NewStore creates an instance of Store

func (Store) Get

func (s Store) Get(cipherType Type) Cipher

Get retrieves the Cipher by it's type

type Type

type Type string

Type describes the type of encryption of a Cipher

Jump to

Keyboard shortcuts

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