Documentation ¶
Overview ¶
Package localsecrets provides a secrets implementation using a locally locally provided symmetric key. Use NewKeeper to construct a *secrets.Keeper.
As ¶
localsecrets does not support any types for As.
Example ¶
package main import ( "context" "fmt" "log" "gocloud.dev/secrets/localsecrets" ) func main() { // localsecrets.Keeper untilizes the golang.org/x/crypto/nacl/secretbox package // for the crypto implementation, and secretbox requires a secret key // that is a [32]byte. Because most users will have keys which are strings, // the localsecrets package supplies a helper function to convert your key // and also crop it to size, if necessary. secretKey := localsecrets.ByteKey("I'm a secret string!") keeper := localsecrets.NewKeeper(secretKey) // Now we can use keeper to encrypt or decrypt. plaintext := []byte("Hello, Secrets!") ctx := context.Background() ciphertext, err := keeper.Encrypt(ctx, plaintext) if err != nil { log.Fatal(err) } decrypted, err := keeper.Decrypt(ctx, ciphertext) fmt.Println(string(decrypted)) }
Output: Hello, Secrets!
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.