crypto

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKey is returned is the given key is invalid.
	ErrKey = errors.New("invalid key")
	// ErrData is returned is the data is mal-formatted.
	ErrData = errors.New("invalid data")
)

Commons errors.

Functions

This section is empty.

Types

type Decrypter

type Decrypter interface {
	Decrypt(hash []byte) ([]byte, error)
}

Decrypter must be implemented by any hash to decrypt a data.

type Hash

type Hash interface {
	Signer
	Decrypter
}

Hash must be implemented by any hashed to sign and decrypt data.

type PrivateKey

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

PrivateKey is a private key.

func New

func New(key []byte) *PrivateKey

New returns a private key.

func (*PrivateKey) Decrypt

func (k *PrivateKey) Decrypt(hash []byte) ([]byte, error)

Decrypt decrypts the given hash, returns the plain text behind it or a error if it fails to do it.

func (*PrivateKey) Sign

func (k *PrivateKey) Sign(plain []byte) ([]byte, error)

Sign signs the given plain text, returns a hash or a error if it fails to do it.

type Signer

type Signer interface {
	Sign(plain []byte) ([]byte, error)
}

Signer must be implemented by any hash to encrypt a data.

Jump to

Keyboard shortcuts

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