Documentation
¶
Index ¶
- Constants
- Variables
- func CreateRandomString(len int) string
- func GenerateCertificateNumber() string
- func New() string
- func NewLen(length int) string
- func NewLenChars(length int, chars []byte) string
- func RandAsciiBytes(n int) []byte
- func RandStr(n int) (str string)
- func RandStr2(ln int) string
- func RandStringRunes3(n int) string
- func SecureRandomAlphaString(length int) string
- func SecureRandomBytes(length int) []byte
- func SecureRandomString(availableCharBytes string, length int) string
- type MemFile
- type Rand
Constants ¶
const ( // StdLen is a standard length of uniuri string to achieve ~95 bits of entropy. StdLen = 16 // UUIDLen is a length of uniuri string to achive ~119 bits of entropy, closest // to what can be losslessly converted to UUIDv4 (122 bits). UUIDLen = 20 )
Variables ¶
var (
MRand = NewRand()
)
var StdChars = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
StdChars is a set of standard characters allowed in uniuri string.
Functions ¶
func CreateRandomString ¶
func GenerateCertificateNumber ¶
func GenerateCertificateNumber() string
func New ¶
func New() string
New returns a new random string of the standard length, consisting of standard characters.
func NewLen ¶
NewLen returns a new random string of the provided length, consisting of standard characters.
func NewLenChars ¶
NewLenChars returns a new random string of the provided length, consisting of the provided byte slice of allowed characters (maximum 256).
func RandAsciiBytes ¶
A helper function create and fill a slice of length n with characters from a-zA-Z0-9_-. It panics if there are any problems getting random bytes.
func RandStringRunes3 ¶
func SecureRandomAlphaString ¶
func SecureRandomBytes ¶
SecureRandomBytes returns the requested number of bytes using crypto/rand
func SecureRandomString ¶
SecureRandomString returns a string of the requested length, made from the byte characters provided (only ASCII allowed). Uses crypto/rand for security. Will panic if len(availableCharBytes) > 256.
Types ¶
type MemFile ¶
type MemFile interface { fmt.Stringer io.ReadWriteCloser }
func NewMemFile ¶
NewMemFile returns an interface to an in-memory implementation of the file named filename.
The MemFile implements io.ReadWriteCloser Closing the MemFile destroys the MemFile and frees any memory allocated.
If the file does not exist or is not readable, an error is returned.