encryption

package
v1.62.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package encryption defines utilities with regards to cryptography.

Index

Constants

View Source
const KeySize = 32

Variables

This section is empty.

Functions

func DecryptWithKeyPair

func DecryptWithKeyPair(keys IKeyPair, base64EncodedEncryptedMessage string) (decryptedMessage string, err error)

DecryptWithKeyPair decrypts small base64 encoded messages

func EncryptWithPublicKey

func EncryptWithPublicKey(base64EncodedPublicKey string, message string) (encryptedBase64Message string, err error)

EncryptWithPublicKey encrypts small messages using a 32-byte public key (See https://libsodium.gitbook.io/doc/public-key_cryptography/sealed_boxes)

Types

type IKeyPair

type IKeyPair interface {
	fmt.Stringer
	fmt.GoStringer
	json.Marshaler
	// GetPublicKey returns the public key (base64 encoded)
	GetPublicKey() string
	// GetPrivateKey returns the private key (base64 encoded)
	GetPrivateKey() string
}

IKeyPair defines an asymmetric key pair for cryptography.

func GenerateKeyPair

func GenerateKeyPair() (pair IKeyPair, err error)

GenerateKeyPair generates a asymmetric key pair suitable for use with encryption utilities. Works with [NaCl box](https://nacl.cr.yp.to/box.html.)

Jump to

Keyboard shortcuts

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