crypt

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: MIT Imports: 5 Imported by: 0

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 Key

type Key [KeySize]byte

Key is a public or private encryption key

func NewKey

func NewKey(str string) (key Key, err error)

NewKey creates a new key from a base58 string

func (Key) MarshalYAML

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

func (Key) String

func (key Key) String() string

func (*Key) UnmarshalYAML

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

func (Key) Valid

func (key Key) Valid() bool

type KeyPair

type KeyPair struct {
	Public, Private Key
}

A KeyPair is a public, private key pair

func GenerateKeyPair

func GenerateKeyPair() KeyPair

GenerateKeyPair generates a (public, private) encryption key

func (*KeyPair) Decrypt

func (pair *KeyPair) Decrypt(peerPublicKey Key, data []byte) ([]byte, error)

Decrypt decrypts a message using a peer's public key and the local private key

func (*KeyPair) Encrypt

func (pair *KeyPair) Encrypt(peerPublicKey Key, data []byte) []byte

Encrypt encrypts a message using a peer's public key and the local private key

type Nonce

type Nonce = [NonceSize]byte

Nonce is a number used once

Jump to

Keyboard shortcuts

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