lazynacl

package module
v0.0.0-...-bb45fe7 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 4 Imported by: 0

README

lazynacl

End-to-End Encryption an wrapper for Nacl in golang.

Go Report Card

Install
go get github.com/prongbang/lazynacl
Benchmark
BenchmarkLazyNacl_Encrypt-10                       27480             42659 ns/op
BenchmarkLazyNacl_Decrypt-10                       28411             42298 ns/op
BenchmarkLazyNacl_EncryptPrecompute-10             28120             42594 ns/op
BenchmarkLazyNacl_DecryptPrecompute-10             28603             42268 ns/op
How to use
  • Create KeyPair
keyPair := lazynacl.NewKeyPair()
  • Key Exchange
clientKp := lazynacl.NewKeyPair()
serverKp := lazynacl.NewKeyPair()
clientSharedKey := clientKp.Exchange(serverKp.Pk)
serverSharedKey := serverKp.Exchange(clientKp.Pk)
  • Encrypt
plaintext := `Plaintext`
ciphertext, err := lazynacl.EncryptPrecompute(plaintext, clientSharedKey)
  • Decrypt
ciphertext := "ae76477791140129a083a09ff68d5b10460f125c9affdefff48d52d30d774a7c3f42f364ea581eb9b114a65cdbf535171a"
plaintext, err := lazyEzee.DecryptPrecompute(ciphertext, serverSharedKey)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(ciphertext string, keyPair KeyPair) string

func DecryptPrecompute

func DecryptPrecompute(ciphertext string, keyPair KeyPair) string

func Encrypt

func Encrypt(plaintext string, keyPair KeyPair) string

func EncryptPrecompute

func EncryptPrecompute(plaintext string, keyPair KeyPair) string

func NewNonce

func NewNonce() [24]byte

NewNonce for random You must use a different nonce for each message you encrypt with the same key. Since the nonce here is 192 bits long, a random value provides a sufficiently small probability of repeats.

Types

type KeyPair

type KeyPair struct {
	Pk *[32]byte `json:"pk"`
	Sk *[32]byte `json:"sk"`
}

func NewKeyPair

func NewKeyPair() KeyPair

func (KeyPair) Exchange

func (k KeyPair) Exchange(pk *[32]byte) KeyPair

Jump to

Keyboard shortcuts

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