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 ¶
- func GetRandomPort() (int, error)
- func NewRand(seed int64) *rand.Rand
- func RandomEmail(seed int64) string
- func RandomInt(min, max int64, seed int64) int64
- func RandomKeypair(length int) (*rsa.PrivateKey, *rsa.PublicKey)
- func RandomKeypairFile(length int, privateFilePath string, publicFilePath string) error
- func RandomName(seed int64) string
- func RandomPassword(length int, seed int64) string
- func RandomPrivateKeyFile(length int, filePath string) error
- func RandomString(n int, seed int64) string
- func RandomURL(seed int64) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRandomPort ¶
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 RandomKeypair ¶
func RandomKeypair(length int) (*rsa.PrivateKey, *rsa.PublicKey)
RandomKeypair returns a random RSA keypair
func RandomKeypairFile ¶
RandomKeypairFile generates a random RSA keypair and writes it to files
func RandomPassword ¶
RandomPassword returns a random password.
func RandomPrivateKeyFile ¶
RandomPrivateKeyFile generates a random RSA private key and writes it to a file
func RandomString ¶
RandomString returns a random string of length n.
Types ¶
This section is empty.