lazyxchacha
Lazy XChaCha20-Poly1305 in golang.
Install
go get github.com/prongbang/lazyxchacha
Benchmark
BenchmarkEncrypt-10 1220955 984.5 ns/op 944 B/op 5 allocs/op
BenchmarkDecrypt-10 1706475 695.0 ns/op 576 B/op 4 allocs/op
How to use
keyPair := lazyxchacha.NewKeyPair()
// Generate KeyPair
clientKp := lazyxchacha.NewKeyPair()
serverKp := lazyxchacha.NewKeyPair()
serverKx := serverKp.Exchange(clientKp.Pk)
clientKx := clientKp.Exchange(serverKp.Pk)
serverSharedKey, _ := serverKx.Secret()
clientSharedKey, _ := clientKx.Secret()
lazyXchacha := lazyxchacha.New()
key, _ := lazyXchacha.RandomKey()
plaintext := "text"
ciphertext, err := lazyXchacha.Encrypt(plaintext, key)
lazyXchacha := lazyxchacha.New()
key := "e7de22e8"
ciphertext := "f6a1bd8"
plaintext, err := lazyXchacha.Decrypt(ciphertext, key)