package xrand

import "git.sr.ht/~jamesponddotco/xstd-go/xcrypto/xrand"

Package xrand provides helper functions for generating random numbers.

Index

Functions

func Bytes

func Bytes(size int) []byte

Bytes returns an amount of cryptographically-secure random bytes equal to the the specified size.

The bytes are generated using the crypto/rand package and will panic if crypto/rand fails to generate the requested amount of bytes.

Defaults to 32 if no size is specified.

func BytesWithReader

func BytesWithReader(size int, reader io.Reader) []byte

BytesWithReader is like Bytes, but allows you to specify your own reader.

Types

type UUID

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

UUID represents a 128-bit Universal Unique Identifier (UUID) as defined in RFC 4122.

func (*UUID) GenerateV4

func (u *UUID) GenerateV4() string

Generate generates a UUIDv4 and returns it as a string.

Source Files

bytes.go uuid.go xrand.go

Version
v0.13.1 (latest)
Published
Jan 29, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
4 days ago

Tools for package owners.