gen

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DigitsAndEnglish = `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
	DigitsAndSwedish = `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖabcdefghijklmnopqrstuvwxyzåäö`
	DigitsAndGerman  = `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜẞabcdefghijklmnopqrstuvwxyzäöüß`
)

Keep in mind that some symbols take >1 byte and if used to generate random string, the result may not be human-readable.

åäö - this string, for example, takes 6 bytes, not 3. So if you try to take random bytes from here, you will possibly get something like `�å`

Use tools like this one to check https://mothereff.in/byte-counter

Variables

This section is empty.

Functions

func GenerateRandomBytes

func GenerateRandomBytes(n int) []byte

GenerateRandomBytes returns a random byte slice of latin symbols and/or numbers.

It is NOT crypto safe and is meant to be used in tests or non-sensitive operations only.

func GenerateRandomBytesFromSet

func GenerateRandomBytesFromSet(n int, charSet []byte) []byte

func GenerateRandomBytesSet

func GenerateRandomBytesSet(lens []int) [][]byte

GenerateRandomBytesSet returns set of random byte slices of latin symbols and/or numbers.

It is NOT crypto safe and is meant to be used in tests or non-sensitive operations only.

func GenerateRandomBytesSetFromSet

func GenerateRandomBytesSetFromSet(lens []int, charSet []byte) [][]byte

func GenerateRandomString

func GenerateRandomString(n int) string

GenerateRandomString returns a random string of latin symbols and/or numbers.

It is NOT cryptographically secure and is meant to be used in tests or non-sensitive operations only

func GenerateRandomStringFromSet

func GenerateRandomStringFromSet(n int, charSet []byte) string

GenerateRandomStringFromSet returns a random string of symbols you provide in charSet.

It is NOT cryptographically secure and is meant to be used in tests or non-sensitive operations only

func GenerateRandomStringSet

func GenerateRandomStringSet(lens []int) []string

GenerateRandomStringSet returns set of random strings of latin symbols and/or numbers.

It is NOT cryptographically secure and is meant to be used in tests or non-sensitive operations only

func GenerateRandomStringSetFromSet

func GenerateRandomStringSetFromSet(lens []int, charSet []byte) []string

GenerateRandomStringSetFromSet returns set of random strings made from charSet you provide.

It is NOT cryptographically secure and is meant to be used in tests or non-sensitive operations only

Types

This section is empty.

Jump to

Keyboard shortcuts

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