Documentation ¶
Index ¶
- Constants
- type Cryptographical
- func (r *Cryptographical) Bytes() (data []byte)
- func (r *Cryptographical) BytesCustom(n int, charset []byte) (data []byte)
- func (r *Cryptographical) BytesCustomErr(n int, charset []byte) (data []byte, err error)
- func (r *Cryptographical) BytesErr() (data []byte, err error)
- func (r *Cryptographical) Int(max *big.Int) (value *big.Int)
- func (r *Cryptographical) IntErr(max *big.Int) (value *big.Int, err error)
- func (r *Cryptographical) Intn(n int) (value int)
- func (r *Cryptographical) IntnErr(n int) (value int, err error)
- func (r *Cryptographical) Prime(bits int) (prime *big.Int, err error)
- func (r *Cryptographical) Read(p []byte) (n int, err error)
- func (r *Cryptographical) StringCustom(n int, characters string) (data string)
- func (r *Cryptographical) StringCustomErr(n int, characters string) (data string, err error)
- type Mathematical
- func (r *Mathematical) Bytes() (data []byte)
- func (r *Mathematical) BytesCustom(n int, charset []byte) (data []byte)
- func (r *Mathematical) BytesCustomErr(n int, charset []byte) (data []byte, err error)
- func (r *Mathematical) BytesErr() (data []byte, err error)
- func (r *Mathematical) Int(max *big.Int) (value *big.Int)
- func (r *Mathematical) IntErr(max *big.Int) (value *big.Int, err error)
- func (r *Mathematical) Intn(n int) int
- func (r *Mathematical) IntnErr(n int) (output int, err error)
- func (r *Mathematical) Prime(bits int) (prime *big.Int, err error)
- func (r *Mathematical) Read(p []byte) (n int, err error)
- func (r *Mathematical) StringCustom(n int, characters string) (data string)
- func (r *Mathematical) StringCustomErr(n int, characters string) (data string, err error)
- type Provider
Constants ¶
const ( // CharSetAlphabeticLower are literally just valid alphabetic lowercase printable ASCII chars. CharSetAlphabeticLower = "abcdefghijklmnopqrstuvwxyz" // CharSetAlphabeticUpper are literally just valid alphabetic uppercase printable ASCII chars. CharSetAlphabeticUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" // CharSetAlphabetic are literally just valid alphabetic printable ASCII chars. CharSetAlphabetic = CharSetAlphabeticLower + CharSetAlphabeticUpper // CharSetNumeric are literally just valid numeric chars. CharSetNumeric = "0123456789" // CharSetNumericHex are literally just valid hexadecimal printable ASCII chars. CharSetNumericHex = CharSetNumeric + "ABCDEF" // CharSetSymbolic are literally just valid symbolic printable ASCII chars. CharSetSymbolic = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" // CharSetSymbolicRFC3986Unreserved are RFC3986 unreserved symbol characters. // See https://datatracker.ietf.org/doc/html/rfc3986#section-2.3. CharSetSymbolicRFC3986Unreserved = "-._~" // CharSetAlphaNumeric are literally just valid alphanumeric printable ASCII chars. CharSetAlphaNumeric = CharSetAlphabetic + CharSetNumeric // CharSetASCII are literally just valid printable ASCII chars. CharSetASCII = CharSetAlphabetic + CharSetNumeric + CharSetSymbolic // CharSetRFC3986Unreserved are RFC3986 unreserved characters. // See https://datatracker.ietf.org/doc/html/rfc3986#section-2.3. CharSetRFC3986Unreserved = CharSetAlphabetic + CharSetNumeric + CharSetSymbolicRFC3986Unreserved // CharSetUnambiguousUpper are a set of unambiguous uppercase characters. CharSetUnambiguousUpper = "ABCDEFGHJKLMNPQRTUVWYXZ2346789" )
const (
// DefaultN is the default value of n.
DefaultN = 72
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cryptographical ¶
type Cryptographical struct{}
Cryptographical is the production random.Provider which uses crypto/rand.
func (*Cryptographical) Bytes ¶
func (r *Cryptographical) Bytes() (data []byte)
Bytes returns random data as bytes with the standard random.DefaultN length and can contain any byte values (including unreadable byte values). If an error is returned from the random read this function ignores it.
func (*Cryptographical) BytesCustom ¶
func (r *Cryptographical) BytesCustom(n int, charset []byte) (data []byte)
BytesCustom returns random data as bytes with n length and can contain only byte values from the provided values. If n is less than 1 then DefaultN is used instead. If an error is returned from the random read this function ignores it.
func (*Cryptographical) BytesCustomErr ¶
func (r *Cryptographical) BytesCustomErr(n int, charset []byte) (data []byte, err error)
BytesCustomErr returns random data as bytes with n length and can contain only byte values from the provided values. If n is less than 1 then DefaultN is used instead. If an error is returned from the random read this function returns it.
func (*Cryptographical) BytesErr ¶
func (r *Cryptographical) BytesErr() (data []byte, err error)
BytesErr returns random data as bytes with the standard random.DefaultN length and can contain any byte values (including unreadable byte values). If an error is returned from the random read this function returns it.
func (*Cryptographical) Int ¶
func (r *Cryptographical) Int(max *big.Int) (value *big.Int)
Int returns a random *big.Int with a maximum of max.
func (*Cryptographical) IntErr ¶
IntErr returns a random *big.Int error combination with a maximum of max.
func (*Cryptographical) Intn ¶
func (r *Cryptographical) Intn(n int) (value int)
Intn returns a random int with a maximum of n.
func (*Cryptographical) IntnErr ¶
func (r *Cryptographical) IntnErr(n int) (value int, err error)
IntnErr returns a random int error combination with a maximum of n.
func (*Cryptographical) Prime ¶
func (r *Cryptographical) Prime(bits int) (prime *big.Int, err error)
Prime returns a number of the given bit length that is prime with high probability. Prime will return error for any error returned by rand.Read or if bits < 2.
func (*Cryptographical) Read ¶
func (r *Cryptographical) Read(p []byte) (n int, err error)
Read implements the io.Reader interface.
func (*Cryptographical) StringCustom ¶
func (r *Cryptographical) StringCustom(n int, characters string) (data string)
StringCustom is an overload of BytesCustom which takes a characters string and returns a string.
func (*Cryptographical) StringCustomErr ¶
func (r *Cryptographical) StringCustomErr(n int, characters string) (data string, err error)
StringCustomErr is an overload of BytesCustomWithErr which takes a characters string and returns a string.
type Mathematical ¶
type Mathematical struct {
// contains filtered or unexported fields
}
Mathematical is the random.Provider which uses math/rand and is COMPLETELY UNSAFE FOR PRODUCTION IN MOST SITUATIONS. Use random.Cryptographical instead.
func NewMathematical ¶
func NewMathematical() *Mathematical
NewMathematical runs rand.Seed with the current time and returns a random.Provider, specifically *random.Mathematical.
func (*Mathematical) Bytes ¶
func (r *Mathematical) Bytes() (data []byte)
Bytes returns random data as bytes with the standard random.DefaultN length and can contain any byte values (including unreadable byte values). If an error is returned from the random read this function ignores it.
func (*Mathematical) BytesCustom ¶
func (r *Mathematical) BytesCustom(n int, charset []byte) (data []byte)
BytesCustom returns random data as bytes with n length and can contain only byte values from the provided values. If n is less than 1 then DefaultN is used instead. If an error is returned from the random read this function ignores it.
func (*Mathematical) BytesCustomErr ¶
func (r *Mathematical) BytesCustomErr(n int, charset []byte) (data []byte, err error)
BytesCustomErr returns random data as bytes with n length and can contain only byte values from the provided values. If n is less than 1 then DefaultN is used instead. If an error is returned from the random read this function returns it.
func (*Mathematical) BytesErr ¶
func (r *Mathematical) BytesErr() (data []byte, err error)
BytesErr returns random data as bytes with the standard random.DefaultN length and can contain any byte values (including unreadable byte values). If an error is returned from the random read this function returns it.
func (*Mathematical) Int ¶
func (r *Mathematical) Int(max *big.Int) (value *big.Int)
Int returns a random *big.Int with a maximum of max.
func (*Mathematical) IntErr ¶
IntErr returns a random *big.Int error combination with a maximum of max.
func (*Mathematical) Intn ¶
func (r *Mathematical) Intn(n int) int
Intn returns a random int with a maximum of n.
func (*Mathematical) IntnErr ¶
func (r *Mathematical) IntnErr(n int) (output int, err error)
IntnErr returns a random int error combination with a maximum of n.
func (*Mathematical) Prime ¶
func (r *Mathematical) Prime(bits int) (prime *big.Int, err error)
Prime returns a number of the given bit length that is prime with high probability. Prime will return error for any error returned by rand.Read or if bits < 2.
func (*Mathematical) Read ¶
func (r *Mathematical) Read(p []byte) (n int, err error)
Read implements the io.Reader interface.
func (*Mathematical) StringCustom ¶
func (r *Mathematical) StringCustom(n int, characters string) (data string)
StringCustom is an overload of BytesCustom which takes a characters string and returns a string.
func (*Mathematical) StringCustomErr ¶
func (r *Mathematical) StringCustomErr(n int, characters string) (data string, err error)
StringCustomErr is an overload of BytesCustomWithErr which takes a characters string and returns a string.
type Provider ¶
type Provider interface { io.Reader // BytesErr returns random data as bytes with the standard random.DefaultN length and can contain any byte values // (including unreadable byte values). If an error is returned from the random read this function returns it. BytesErr() (data []byte, err error) // Bytes returns random data as bytes with the standard random.DefaultN length and can contain any byte values // (including unreadable byte values). If an error is returned from the random read this function ignores it. Bytes() (data []byte) // BytesCustomErr returns random data as bytes with n length and can contain only byte values from the provided // values. If n is less than 1 then DefaultN is used instead. If an error is returned from the random read this function // returns it. BytesCustomErr(n int, charset []byte) (data []byte, err error) // StringCustomErr is an overload of BytesCustomWithErr which takes a characters string and returns a string. StringCustomErr(n int, characters string) (data string, err error) // BytesCustom returns random data as bytes with n length and can contain only byte values from the provided // values. If n is less than 1 then DefaultN is used instead. BytesCustom(n int, charset []byte) (data []byte) // StringCustom is an overload of GenerateCustom which takes a characters string and returns a string. StringCustom(n int, characters string) (data string) // Intn returns a random integer with a maximum of n. Intn(n int) (value int) // IntnErr returns a random int error combination with a maximum of n. IntnErr(n int) (value int, err error) // IntErr returns a random *big.Int error combination with a maximum of max. IntErr(max *big.Int) (value *big.Int, err error) // Int returns a random *big.Int with a maximum of max. Int(max *big.Int) (value *big.Int) // Prime returns a number of the given bit length that is prime with high probability. Prime will return error for any // error returned by rand.Read or if bits < 2. Prime(bits int) (prime *big.Int, err error) }
Provider of random functions and functionality.