salted

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package salted handles salted identifiers.

A salted identifier is a pair consisting of an identifier and a random salt. Salted identifiers are used to prevent malicious agents to guess valid identifiers too easily.

Index

Constants

View Source
const SaltLength = 22

SaltLength is the number of bits of the salt that are really used. The more significant bits are ignored.

Variables

This section is empty.

Functions

This section is empty.

Types

type Segment

type Segment struct {
	Id   uint32
	Salt uint32
}

Segment represents a segment encoding an id and a salt. This class is used to encode and decode such segments. The encoded form is a short string that can be used as an URI segment.

func Decode

func Decode(str string) (ret Segment, err error)

Decode creates a Segment from its URI representation.

func FromRequest

func FromRequest(request *server.Request) (segment Segment, err error)

FromRequest creates a Segment from the last segment of the URL of a request.

func New

func New(id uint32) (ret Segment, err error)

New creates a Segment with the given id and a random salt.

func (Segment) Encode

func (self Segment) Encode() (str string, err error)

Encode returns the URI representation of the Segment.

Jump to

Keyboard shortcuts

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