rand

package
v0.0.0-...-926d7b1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const RememberTokenBytes = 32

RememberTokenBytes specifies the length of the remember token in bytes. According to the Open Web App. Sec. Project (OWASP), this should be at least 128 bits == 16 bytes. We are using 256 bits == 32 bytes. See: https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#session-id-length for details.

Variables

This section is empty.

Functions

func Bytes

func Bytes(n int) ([]byte, error)

Bytes will help us generate n random bytes, or will return an error if there was one. This uses the crypto/rand package so it is safe to use with things like remember tokens.

func NBytes

func NBytes(base64Encoded string) (int, error)

NBytes returns the number of bytes used in any string generated by the String or RememberToken functions in this package.

func RememberToken

func RememberToken() (string, error)

RememberToken is a helper function designed to generate remember tokens of a predetermined byte size.

func String

func String(nBytes int) (string, error)

String will generate a byte slice of size nBytes and then return a string that is the base64 URL encoded version of that byte slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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