secret

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2018 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDecryption = errgo.New("decryption error")

Functions

This section is empty.

Types

type Codec

type Codec struct {
	// contains filtered or unexported fields
}

Codec is used to create an encrypted messages that will be decrypted by the same service. This should be used for cookies and other data that needs to be sent through the client but must be verifiable as originally coming from this service.

func NewCodec

func NewCodec(key *bakery.KeyPair) *Codec

NewCodec creates a new Codec using the given key.

func (*Codec) Decode

func (c *Codec) Decode(s string, v interface{}) error

Decode unmarshals a value from the given buffer that must have been marshaled with a Codec using the same key. If there was an error decrypting buf the returned error will have a cause of ErrDecryption.

func (*Codec) Encode

func (c *Codec) Encode(v interface{}) (string, error)

Encode marshals the given value in such a way that it can only be unmarshaled by a Codec using the same key. The encoded output will be in the base64 url safe alphabet.

Jump to

Keyboard shortcuts

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