stringutil

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var RANDOM = rand.New(rand.NewSource(time.Now().UnixNano()))

Functions

func CryptoRandom

func CryptoRandom(count int, start int, end int, letters bool, numbers bool, chars ...rune) (string, error)

func CryptoRandomAlphaNumeric

func CryptoRandomAlphaNumeric(count int) (string, error)

func CryptoRandomAlphaNumericCustom

func CryptoRandomAlphaNumericCustom(count int, letters bool, numbers bool) (string, error)

func CryptoRandomAlphabetic

func CryptoRandomAlphabetic(count int) (string, error)

func CryptoRandomAscii

func CryptoRandomAscii(count int) (string, error)

func CryptoRandomNonAlphaNumeric

func CryptoRandomNonAlphaNumeric(count int) (string, error)

func CryptoRandomNumeric

func CryptoRandomNumeric(count int) (string, error)

func Random

func Random(count int, start int, end int, letters bool, numbers bool, chars ...rune) (string, error)

func RandomAlphaNumeric

func RandomAlphaNumeric(count int) (string, error)

func RandomAlphaNumericCustom

func RandomAlphaNumericCustom(count int, letters bool, numbers bool) (string, error)

func RandomAlphabetic

func RandomAlphabetic(count int) (string, error)

func RandomAscii

func RandomAscii(count int) (string, error)

func RandomNonAlphaNumeric

func RandomNonAlphaNumeric(count int) (string, error)

func RandomNumeric

func RandomNumeric(count int) (string, error)

func RandomSeed

func RandomSeed(count int, start int, end int, letters bool, numbers bool, chars []rune, random *rand.Rand) (string, error)
Example
var seed int64 = 10 // If you change this seed #, the random sequence below will change
random := rand.New(rand.NewSource(seed))
chars := []rune{'1', '2', '3', 'a', 'b', 'c'}

rand1, _ := RandomSeed(5, 0, 0, true, true, nil, random)      // RandomAlphaNumeric (Alphabets and numbers possible)
rand2, _ := RandomSeed(5, 0, 0, true, false, nil, random)     // RandomAlphabetic (Only alphabets)
rand3, _ := RandomSeed(5, 0, 0, false, true, nil, random)     // RandomNumeric (Only numbers)
rand4, _ := RandomSeed(5, 32, 127, false, false, nil, random) // RandomAscii (Alphabets, numbers, and other ASCII chars)
rand5, _ := RandomSeed(5, 0, 0, true, true, chars, random)    // RandomSeed with custom characters

fmt.Println(rand1)
fmt.Println(rand2)
fmt.Println(rand3)
fmt.Println(rand4)
fmt.Println(rand5)
Output:

3ip9v
MBrbj
88935
H_I;E
2b2ca

Types

This section is empty.

Jump to

Keyboard shortcuts

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