crypt

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputePublicKey

func ComputePublicKey(secret []byte) ([]byte, error)

ComputePublicKey will compute a key based on the secret

func ComputeSharedKey

func ComputeSharedKey(senderKey []byte, publicKey []byte) []byte

ComputeSharedKey compute a shareKey based on two keys

func DecryptPayload

func DecryptPayload(sharedKey []byte, encryptedPayload []byte, nonce []byte) []byte

DecryptPayload will decrypt a payload based on a key and nonce

func EncryptPayload

func EncryptPayload(sharedKey []byte, payload []byte, nonce []byte) []byte

EncryptPayload will encrypt payload based on a key and nonce

func GenerateKeys

func GenerateKeys(generateKeys string) error

GenerateKeys will generate key/pub and save into file

func GetPrivateKey

func GetPrivateKey(publicKey []byte) []byte

GetPrivateKey will get the pk for a pub

func GetPublicKeys

func GetPublicKeys() [][]byte

GetPublicKeys will get all pubs in memory

func NewRandomKey

func NewRandomKey() ([]byte, error)

NewRandomKey generate new key

func NewRandomNonce

func NewRandomNonce() ([]byte, error)

NewRandomNonce generate new nonce

func PutKeyPair

func PutKeyPair(pair KeyPair)

PutKeyPair will put a pair into pairs var

func WritePrivateKeyFile

func WritePrivateKeyFile(key string, filepath string) error

WritePrivateKeyFile creates a json file with the private key

func WritePublicKeyFile

func WritePublicKeyFile(key string, filepath string) error

WritePublicKeyFile creates a file with the pubKey

Types

type KeyPair

type KeyPair struct {
	PrivateKey []byte
	PublicKey  []byte
}

KeyPair holds PrivateKey and PublicKey

Jump to

Keyboard shortcuts

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