Documentation
¶
Index ¶
Constants ¶
const ( RangeFull = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" RangePassword = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789&~#([-|_^@)]{}$*,?;.:/!<>" RangeAlnumLower = "abcdefghijklmnopqrstuvwxyz0123456789" RangeNumeric = "0123456789" )
Variables ¶
This section is empty.
Functions ¶
func Code ¶
Code generates a random string made of ln characters taken from set. For example to generate a random password of 32 characters, you can simply call Code(32, rndpass.RangePassword). This method uses golang's math/rand random generator and is not considered secure, but can come in handy in some cases as it cannot fail.
If you need higher quality randomness, please use SecureCode()
func MustSecureCode ¶
MustSecureCode will generate a code similar to SecureCode, and will panic should the random generator fail to generate randomness (which is the proper action to take in this case).
func SecureCode ¶
SecureCode method works similarly to Code() except it uses a secure random source (if rnd is nil, crypto/rand.Reader is used by default) and may return an error if reading from the random source fails (it shouldn't). This method will be slower than Code() but comes with a much higher randomness quality.
Types ¶
This section is empty.