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.WithNewReaderOptionRandomReader(ExampleReader))
s, err := randz.ReadString(r, 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 DefaultStringReaderRandomSource = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
Variables ¶
View Source
var (
StringReader = NewReader()
)
Functions ¶
func NewReader ¶
func NewReader(opts ...NewReaderOption) io.Reader
Types ¶
type NewReaderOption ¶ added in v0.0.57
type NewReaderOption func(r *reader)
func WithNewReaderOptionRandomReader ¶ added in v0.0.57
func WithNewReaderOptionRandomReader(random io.Reader) NewReaderOption
func WithNewReaderRandomSource ¶ added in v0.0.57
func WithNewReaderRandomSource(s string) NewReaderOption
Click to show internal directories.
Click to hide internal directories.