rndstr

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: BSD-3-Clause Imports: 3 Imported by: 2

README

GoDoc

Simple random string generator

This allows generating random strings very easily.

	fmt.Printf("Random string: %s\n", rndstr.Simple(16, rndstr.Alnum))

	// or to generate a secure string, using crypto/rand
	secureStr := rndstr.SimpleReader(16, rndstr.Alnum, rand.Reader)

Documentation

Index

Constants

View Source
const (
	Alpha    = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	Alnum    = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
	Code     = "ABCDEFGHJKLMNPRSTUVWXYZ23456789"
	Password = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789&~#([-|_^@)]{}$*,?;.:/!<>"
)

Variables

This section is empty.

Functions

func Simple

func Simple(l int, rng string) string

Simple is a simple generator using a given len and range. Example use: rndstr.Simple(10, rndstr.Alnum)

func SimpleFastReader

func SimpleFastReader(l int, rng string, src io.Reader) (string, error)

SimpleFastReader can be used with a random source, such as crypto/rand

Unsafe for secure operations but fast.

Usage: rndstr.SimpleFastReader(10, rndstr.Alnum, rand.Reader)

func SimpleReader

func SimpleReader(l int, rng string, src io.Reader) (string, error)

SimpleReader can be used with a random source, such as crypto/rand

This is fairly slow and will consume at least 4 bytes of random input per generated character. This is however secure and follows best practices in random number generation.

Usage: rndstr.SimpleReader(10, rndstr.Alnum, rand.Reader)

Types

This section is empty.

Jump to

Keyboard shortcuts

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