crypt

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: MIT Imports: 6 Imported by: 0

README

crypt

Documentation

Index

Constants

View Source
const (
	// KeySize is the size of an encryption key in bytes
	KeySize = 32
	// NonceSize is the size of a nonce in bytes
	NonceSize = 24
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Nonce

type Nonce = [NonceSize]byte

Nonce is a number used once.

type PrivateKey

type PrivateKey [KeySize * 2]byte

PrivateKey is a private encryption key

func Generate

func Generate() (PrivateKey, error)

Generate generates a new PrivateKey.

func NewPrivateKey

func NewPrivateKey(str string) (key PrivateKey, err error)

NewKey creates a new key from a base58 string.

func (PrivateKey) Decrypt

func (key PrivateKey) Decrypt(data []byte) (PublicKey, []byte, error)

Decrypt decrypts data that was encrypted via a private key. The peer's public key is sent along with the data.

func (PrivateKey) Encrypt

func (key PrivateKey) Encrypt(peersPublicKey PublicKey, data []byte) []byte

Encrypt encrypts data using the private key intended for the peer public key.

func (PrivateKey) MarshalYAML

func (key PrivateKey) MarshalYAML() (interface{}, error)

MarshalYAML marshales the key for use in a YAML file.

func (PrivateKey) PublicKey

func (key PrivateKey) PublicKey() PublicKey

func (PrivateKey) String

func (key PrivateKey) String() string

String returns the base58 encoded representation of the private key.

func (*PrivateKey) UnmarshalYAML

func (key *PrivateKey) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshales the key from a YAML file.

type PublicKey

type PublicKey [KeySize]byte

PublicKey is a public encryption key

func NewPublicKey

func NewPublicKey(str string) (key PublicKey, err error)

NewKey creates a new key from a base58 string.

func (PublicKey) MarshalYAML

func (key PublicKey) MarshalYAML() (interface{}, error)

MarshalYAML marshals the public key for a YAML file.

func (PublicKey) String

func (key PublicKey) String() string

String returns the base58 encoded public key.

func (*PublicKey) UnmarshalYAML

func (key *PublicKey) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals the public key from a YAML file.

Jump to

Keyboard shortcuts

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