pyfernet

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidKey = errors.New("Fernet key must be 32 url-safe base64-encoded bytes.")

ValueError Fernet raises for a key that is not 32 url safe base64 bytes

View Source
var ErrInvalidToken = errors.New("InvalidToken")

InvalidToken cryptography raises for a malformed, forged or undecryptable token

Functions

func GenerateKey

func GenerateKey() []byte

Url safe base64 of 32 random bytes, padded as cryptography emits it

Types

type Fernet

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

func New

func New(key []byte) (*Fernet, error)

Fernet over a url safe base64 key, the error matching the ValueError cryptography raises

func (*Fernet) Decrypt

func (f *Fernet) Decrypt(token []byte) ([]byte, error)

Plaintext of a token without a ttl check, ErrInvalidToken for every failure cryptography folds into it

func (*Fernet) Encrypt

func (f *Fernet) Encrypt(data []byte) []byte

Token for data stamped with the current time and a random IV

func (*Fernet) EncryptAtTime

func (f *Fernet) EncryptAtTime(data []byte, at int64, iv []byte) []byte

Token for data with an explicit timestamp and IV, the spec vector form

Jump to

Keyboard shortcuts

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