confuse

package
v0.0.0-...-ef1e3e3 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultAlphabet   = []byte("QWERTYUIOPLKJHGFDSAZXCVBNMabcdefghijklmnopqrstuvwxyz")
	DefaultDigit      = []byte("0123456789")
	DefaultAlphaDigit = []byte("QWERTYUIOPLKJHGFDSAZXCVBNMabcdefghijklmnopqrstuvwxyz0123456789")
	DefaultSymbol     = []byte("QWERTYUIOPLKJHGFDSAZXCVBNMabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_{|}~`") //nolint: lll
)

Previous defined bytes, do not change this.

Functions

func AlphaNumber

func AlphaNumber(length int) string

AlphaNumber rand string with give length, which Contains number and letters

func AlphaNumberBytes

func AlphaNumberBytes(length int) []byte

AlphaNumberBytes rand string with give length, which Contains number and letters

func Alphabet

func Alphabet(length int) string

Alphabet rand alpha with give length, which Contains only letters

func AlphabetBytes

func AlphabetBytes(length int) []byte

AlphabetBytes rand alpha with give length, which Contains only letters

func Bytes

func Bytes(length int, alphabets ...byte) []byte

Bytes rand bytes, if not alphabets, it will use DefaultAlphabet.

func Float64R

func Float64R(min, max float64) float64

Float64R returns, as an float64, a non-negative pseudo-random number in the half-open interval [min,max). It panics if max < min.

func Generate

func Generate(n int) string

Generate a random string which is complex enough. which use lower, upper and digit, and meets complexity.

func Int32R

func Int32R(min, max int32) int32

Int32R returns, as an int32, a non-negative pseudo-random number in the half-open interval [min,max). It panics if max < min.

func Int64R

func Int64R(min, max int64) int64

Int64R returns, as an int64, a non-negative pseudo-random number in the half-open interval [min,max). It panics if max < min.

func IntR

func IntR(min, max int) int

IntR returns, as an int, a non-negative pseudo-random number in the half-open interval [min,max). It panics if max < min.

func IsComplexEnough

func IsComplexEnough(s string) bool

IsComplexEnough return True if s meets complexity settings. which use lower, upper and digit, and meets complexity.

func NR

func NR[Int intType](min, max Int) Int

NR returns a pseudo-random number in the half-open interval [min,max) from the default Source. The type parameter Int can be any integer type. It panics if max < min.

func Number

func Number(length int) string

Number rand string with give length, which Contains only number

func NumberBytes

func NumberBytes(length int) []byte

NumberBytes rand string with give length, which Contains only number

func String

func String(length int, alphabets ...byte) string

String rand bytes, if not alphabets, it will use DefaultAlphabet.

func Symbol

func Symbol(length int) string

Symbol rand symbol with give length, which Contains number, letters and specific symbol

func SymbolBytes

func SymbolBytes(length int) []byte

SymbolBytes rand symbol with give length, which Contains number, letters and specific symbol

func Uint32R

func Uint32R(min, max uint32) uint32

Uint32R returns, as an uint32, a non-negative pseudo-random number in the half-open interval [min,max). It panics if max < min.

func Uint64R

func Uint64R(min, max uint64) uint64

Uint64R returns, as an uint64, a non-negative pseudo-random number in the half-open interval [min,max). It panics if max < min.

func UintR

func UintR(min, max uint) uint

UintR returns, as an uint, a non-negative pseudo-random number in the half-open interval [min,max). It panics if max < min.

Types

type Complexity

type Complexity struct {
	// contains filtered or unexported fields
}

Complexity setting

func NewComplexity

func NewComplexity(opts ...Option) *Complexity

NewComplexity new complexity with option default use lower, upper and digit to generate a random string, and not meets complexity.

func (*Complexity) Generate

func (sf *Complexity) Generate(n int) string

Generate a random string which is complex enough.

func (*Complexity) IsComplexEnough

func (sf *Complexity) IsComplexEnough(s string) bool

IsComplexEnough return True if s meets complexity settings

type Option

type Option func(*complexityConfig)

Option for Complexity

func WithAll

func WithAll() Option

WithAll use lower upper digit spec and enable meet complexity

func WithDigit

func WithDigit() Option

WithDigit use digit

func WithLower

func WithLower() Option

WithLower use lower

func WithLowerUpper

func WithLowerUpper() Option

WithLowerUpper use lower upper

func WithLowerUpperDigit

func WithLowerUpperDigit() Option

WithLowerUpperDigit use lower upper digit

func WithMeet

func WithMeet() Option

WithMeet enable meet complexity

func WithSpec

func WithSpec() Option

WithSpec use spec

func WithUpper

func WithUpper() Option

WithUpper use upper

Jump to

Keyboard shortcuts

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