modulepackage
1.0.0
Repository: https://github.com/aaronland/go-secretbox.git
Documentation: pkg.go.dev
# README
go-secretbox
A thin wrapper around the Golang secretbox and awnumar/memguard package.
Documentation
Example
package main
import (
"github.com/aaronland/go-secretbox"
"github.com/awnumar/memguard"
"log"
)
func main() {
secret := "s33kret"
salt := "s4lty"
plain := "hello world"
secret_buf := memguard.NewBufferFromBytes([]byte(secret))
defer secret_buf.Destroy()
opts := secretbox.NewSecretboxOptions()
opts.Salt = salt
sb, _ := secretbox.NewSecretboxWithBuffer(secret_buf, opts)
locked, _ := sb.Lock([]byte(plain))
unlocked, _ := sb.Unlock(locked)
if string(unlocked.String()) != plain {
log.Fatal("Unlock failed")
}
}
Error handling omitted for the sake of brevity.
See also
# Functions
NewSecretbox returns a new `Secretbox` instance for 'pswd' and 'opts'.
NewSecretboxOptions returns a `SecretboxOptions` with an empty salt.
NewSecretboxWithBuffer returns a new `Secretbox` instance for 'buf' and 'opts.
NewSecretboxWithEnclave returns a new `Secretbox` instance for 'enclave' and 'opts.
# Structs
type Secretbox is that struct used to encypt and decrypt values.
SecretboxOptions is a struct with options for a specific `Secretbox` instance.