payloads

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encrypt

func Encrypt(p *Payload) (string, error)

Encrypt takes in a payload and returns an encrypted value.

Types

type Cipher

type Cipher struct {
	cipher.Block
}

Cipher provides methods to encrypt and decrypt values

func NewCipher

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

NewCipher returns a new aes Cipher for encrypting values

func (*Cipher) Decrypt

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

Decrypt a value from a Payload to its original string

func (*Cipher) Encrypt

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

Encrypt a value for use in a Payload

type Payload

type Payload struct {
	Value     string
	Timestamp time.Time
	Signature []byte
	Cipher    *Cipher
}

Payload represents the information encoded in cookies. It contains a string Value, a timestamp Timestamp, a byte Signature, and a Cipher.

func Decrypt

func Decrypt(name, encryptedValue, salt string, expiration time.Duration, cipher *Cipher) (*Payload, error)

Decrypt takes in a name, an encrypted value, a salt, expiration time and a cipher, and decrypts the value into a payload.

func New

func New(name, value, salt string, ts time.Time, cipher *Cipher) *Payload

New returns a new payload.

Jump to

Keyboard shortcuts

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