utils

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClampUint32ToUint16

func ClampUint32ToUint16(v uint32) uint16

ClampUint32ToUint16 safely converts uint32 to uint16, clamping to 65535 if overflow.

func DecodeState

func DecodeState(state string) (prefix string, nonce string, err error)

decodeState parses a base64url-encoded state string back to prefix and nonce.

func EncodeState

func EncodeState(prefix, nonce string) string

encodeState builds a base64url-encoded state string as "prefix:nonce".

func SafeIntToInt32

func SafeIntToInt32(v int) int32

SafeIntToInt32 converts int to int32, clamping to int32 max/min.

func SafeIntToUint16

func SafeIntToUint16(v int) uint16

SafeIntToUint16 safely converts int to uint16, clamping to 0-65535.

func SafeIntToUint32

func SafeIntToUint32(v int) uint32

SafeIntToUint32 converts int to uint32, clamping negative values to 0.

func SafeIntToUint64

func SafeIntToUint64(v int) uint64

SafeIntToUint64 converts int to uint64, assuming non-negative input (e.g., from Read()).

func Safeu32ToInt

func Safeu32ToInt(v uint32) int

Safeu32ToInt converts uint32 to int, returning 0 if overflow would occur.

Types

This section is empty.

Jump to

Keyboard shortcuts

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