securetoken

package
v0.38.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

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

Codec provides a means of encoding and decoding values to URL-friendly opaque tokens that clients cannot tamper with. It encodes values using encoding/gob before encrypting them, and uses base64 URL encoding for serializing the encrypted bytes to the token string. It's implemented as a thin wrapper around gorilla/securecookie, which already provides the necessary functionality.

TODO: securecookie redundantly applies two iterations of base64 encoding, increasing the output size (see https://github.com/gorilla/securecookie/issues/36). Since there's not that much code, we should consider modifying/implementing the encoding directly in this package.

func NewCodec

func NewCodec(keyPairs [][]byte) *Codec

func NewRandom

func NewRandom() *Codec

func (*Codec) Decode

func (c *Codec) Decode(value string, dst any) error

func (*Codec) Encode

func (c *Codec) Encode(value any) (string, error)

Jump to

Keyboard shortcuts

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