cookie

package
v0.0.0-...-8f4db56 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Nonce

func Nonce() (nonce string, err error)

func SignedValue

func SignedValue(seed string, key string, value string, now time.Time) string

SignedValue returns a cookie that is signed and can later be checked with Validate

func Validate

func Validate(cookie *http.Cookie, seed string, expiration time.Duration) (value string, t time.Time, ok bool)

Validate ensures a cookie is properly signed

Types

type Cipher

type Cipher struct {
	cipher.Block
}

Cipher provides methods to encrypt and decrypt cookie values

func NewCipher

func NewCipher(secret []byte) (*Cipher, error)

NewCipher returns a new aes Cipher for encrypting cookie values

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(s string) (string, error)

Decrypt a value from a cookie to it's original string

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(value string) (string, error)

Encrypt a value for use in a cookie

Jump to

Keyboard shortcuts

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