diff --git a/main.go b/main.go index 68532d8..6b650ed 100644 --- a/main.go +++ b/main.go @@ -6,10 +6,16 @@ import ( "math/big" ) +type Generator func() (byte,error) + + var chars []byte = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~`!@#$%^&*()_+-=[]{}\\|;:'\",./<>?") var letters []byte = chars[0:52] var digits []byte = chars[52:62] +var letdig []byte = chars[0:62] var symbols []byte = chars[62:94] +var digsym []byte = chars[52:94] +var letsym []byte = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^&*()_+-=[]{}\\|;:'\",./<>?") func gen(s []byte) (byte,error) { nBig, err := crand.Int(crand.Reader, big.NewInt(int64(len(s)))) @@ -32,11 +38,23 @@ func Symbol() (byte,error) { return gen(symbols) } +func LetterDigits() (byte,error) { + return gen(letdig) +} + +func DigitsSymbols() (byte,error) { + return gen(digsym) +} + +func LettersSymbols() (byte, error) { + return gen(letsym) +} + func Char() (byte,error) { return gen(chars) } -func Slice(f func() (byte,error), n int) ([]byte,error) { +func Slice(Generator, n int) ([]byte,error) { ret := make([]byte,0) for i := 0; i < n; i++ { x,err := f()