fernet

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2019 License: BSD-2-Clause Imports: 11 Imported by: 0

README

fernet Travis-CI GoDoc Report card

Go implementation of the Fernet spec.

Documentation

Overview

Package fernet implements the Fernet spec (see https://github.com/fernet/spec).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(token, secret string, now time.Time, ttl time.Duration) (string, error)

Decrypt is the reverse of encrypt. Given a token returned by Encrypt, the same secret, the current time, and a TTL, returns the original message unless either of the following is true: the token has been tampered with, or the TTL has elapsed since the token was generated.

func Encrypt

func Encrypt(msg, secret string, now time.Time) (string, error)

Encrypt uses secret to encrypt and sign msg. Use Decrypt to recover the original message from the token. secret must be a base64-encoded slice of 32 bytes, where the first sixteen bytes are used to sign the token and the second sixteen are used to encrypt the message. now should generally be set to the current time except during testing.

func RandomSecret

func RandomSecret() (string, error)

RandomSecret generates a secret suitable for use with Encrypt.

Types

This section is empty.

Jump to

Keyboard shortcuts

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