Documentation ¶
Overview ¶
Example ¶
package main import ( "bytes" "fmt" "log" randz "github.com/kunitsucom/util.go/crypto/rand" ) var ExampleReader = bytes.NewBufferString("" + "This is a test Reader for example. Please use crypto/rand's Reader in production." + "This is a test Reader for example. Please use crypto/rand's Reader in production." + "This is a test Reader for example. Please use crypto/rand's Reader in production." + "This is a test Reader for example. Please use crypto/rand's Reader in production." + "This is a test Reader for example. Please use crypto/rand's Reader in production." + "This is a test Reader for example. Please use crypto/rand's Reader in production." + "This is a test Reader for example. Please use crypto/rand's Reader in production." + "This is a test Reader for example. Please use crypto/rand's Reader in production." + "This is a test Reader for example. Please use crypto/rand's Reader in production." + "This is a test Reader for example. Please use crypto/rand's Reader in production." + "This is a test Reader for example. Please use crypto/rand's Reader in production." + "This is a test Reader for example. Please use crypto/rand's Reader in production.", ) func main() { r := randz.NewReader(randz.WithRandomReader(ExampleReader)) s, err := r.ReadString(128) if err != nil { log.Printf("(*randz.Reader).ReadString: %v", err) return } fmt.Printf("very secure random string: %s", s) }
Output: very secure random string: Wqr1gr1gjg2n12gUnjmn0gox0gn6jvyunugSunj1ng31ngl07y2xv0jwmn1gUnjmn0grwgy0xm3l2rxwuWqr1gr1gjg2n12gUnjmn0gox0gn6jvyunugSunj1ng31ngl
Index ¶
Examples ¶
Constants ¶
View Source
const DefaultRandomSource = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
Variables ¶
View Source
var (
DefaultReader io.Reader = NewReader()
)
Functions ¶
func ReadString ¶
Types ¶
type ReaderOption ¶
type ReaderOption func(r *Reader)
func WithRandomReader ¶
func WithRandomReader(reader io.Reader) ReaderOption
func WithRandomSource ¶
func WithRandomSource(str string) ReaderOption
Click to show internal directories.
Click to hide internal directories.