Documentation
¶
Overview ¶
Package random provides utilities for generating random data
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Password ¶
Password generates a random password of the specified length using the provided charset. If charset is empty, it uses a default charset containing alphanumeric characters and common symbols.
Example ¶
package main
import (
"fmt"
"github.com/opensvc/om3/v3/util/random"
)
func main() {
// Generate a 16-character password using default charset
pwd1 := random.Password(16, nil)
fmt.Printf("Password length: %d\n", len(pwd1))
// Generate a 12-character alphanumeric password
alphanumeric := []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
pwd2 := random.Password(12, alphanumeric)
fmt.Printf("Alphanumeric password length: %d\n", len(pwd2))
// Generate an 8-character numeric PIN
numeric := []rune("0123456789")
pin := random.Password(8, numeric)
fmt.Printf("Numeric PIN length: %d\n", len(pin))
}
Output: Password length: 16 Alphanumeric password length: 12 Numeric PIN length: 8
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.