generators

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PasswordChars contains alphanumeric chars (0-9, A-Z, a-z), plus "-=+!@#$%^&*."
	PasswordChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-=+!@#$%^&*."
	// AlphaNumChars contains alphanumeric chars (0-9, A-Z, a-z)
	AlphaNumChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
)

Variables

This section is empty.

Functions

func GenerateRandomPassword

func GenerateRandomPassword(length int) (string, error)

GenerateRandomPassword generates a random password with the given length. The password will contain chars picked from the `PasswordChars` constant. If an error happens, the string will be empty and the error will be non-nil.

This is equivalent to `GenerateRandomString(PasswordChars, length)`

func GenerateRandomString

func GenerateRandomString(chars string, length int) (string, error)

GenerateRandomString generates a random string with the given length based on the chars provided. You can use `PasswordChars` or `AlphaNumChars` constants, or even any other string.

Chars from the provided string will be picked uniformly. The provided constants have unique chars, which means that all the chars will have the same probability of being picked. You can use your own strings to change that probability. For example, using "AAAB" you'll have a 75% of probability of getting "A" and 25% of "B"

Types

This section is empty.

Jump to

Keyboard shortcuts

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