rand

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package rand contains utility functions largely for unit testing. WARNING: Do not use the functions in this package that generate rand / seeds for any security related purposes, outside of testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRandomPort

func GetRandomPort() (int, error)

GetRandomPort returns a random port number. The binding address should not need to be configurable as this is a short-lived operation just to discover a random available port. Note that there is a possible race condition here if another process binds to the same port between the time we discover it and the time we use it. This is unlikely to happen in practice, but if it does, the user will need to retry the command. Marking a nosec here because we want this to listen on all addresses to ensure a reliable connection chance for the client. This is based on lessons learned from the sigstore CLI.

func NewRand

func NewRand(seed int64) *rand.Rand

NewRand returns a new instance of rand.Rand with a fixed source.

func RandomEmail

func RandomEmail(seed int64) string

RandomEmail returns a random email address.

func RandomInt

func RandomInt(min, max int64, seed int64) int64

RandomInt returns a random integer between min and max.

func RandomKeypair

func RandomKeypair(length int) (*rsa.PrivateKey, *rsa.PublicKey)

RandomKeypair returns a random RSA keypair

func RandomKeypairFile

func RandomKeypairFile(length int, privateFilePath string, publicFilePath string) error

RandomKeypairFile generates a random RSA keypair and writes it to files

func RandomName

func RandomName(seed int64) string

RandomName returns a random name.

func RandomPassword

func RandomPassword(length int, seed int64) string

RandomPassword returns a random password.

func RandomPrivateKeyFile

func RandomPrivateKeyFile(length int, filePath string) error

RandomPrivateKeyFile generates a random RSA private key and writes it to a file

func RandomString

func RandomString(n int, seed int64) string

RandomString returns a random string of length n.

func RandomURL

func RandomURL(seed int64) string

RandomURL returns a random URL.

Types

This section is empty.

Jump to

Keyboard shortcuts

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