func randomBytesMod(length int, mod byte) (b []byte, err error) {
	if length == 0 {
		return nil, errors.New("length is zero")
	}
	if mod == 0 {
		return nil, errors.New("captcha: bad mod argument for randomBytesMod")
	}
	maxrb := 255 - byte(256%int(mod))
	b = make([]byte, length)
	i := 0
	for {
		r, err := randomBytes(length + (length / 4))
		if err != nil {
			return nil, err
		}
		for _, c := range r {
			if c > maxrb {
				// Skip this number to avoid modulo bias.
				continue
			}
			b[i] = c % mod
			i++
			if i == length {
				return b, nil
			}
		}
	}

}
// randomBytesMod returns a byte slice of the given length, where each byte is
// a random number modulo mod.
randomBytesMod returns a byte slice of the given length, where each byte is
a random number modulo mod.
// randomBytesMod returns a byte slice of the given length where each byte is // a random number modulo mod .
func randomBytesMod(length int, mod byte) (b []byte, err error) {
	if length == 0 {
		return nil, errors.New("length is zero")
	}
	if mod == 0 {
		return nil, errors.New("captcha: bad mod argument for randomBytesMod")
	}
	maxrb := 255 - byte(256%int(mod))
	b = make([]byte, length)
	i := 0
	for {
		r, err := randomBytes(length + (length / 4))
		if err != nil {
			return nil, err
		}
		for _, c := range r {
			if c > maxrb {
				continue
			}
			b[i] = c % mod
			i++
			if i == length {
				return b, nil
			}
		}
	}
}
func randomBytesMod ( length int , mod byte ) ( b [ ] byte , err error ) { if length == 0 { return nil , errors . New ( " " ) } if mod == 0 { return nil , errors . New ( " " ) } maxrb := 255 - byte ( 256 % int ( mod ) ) b = make ( [ ] byte , length ) i := 0 for { r , err := randomBytes ( length + ( length / 4 ) ) if err != nil { return nil , err } for _ , c := range r { if c > maxrb { continue } b [ i ] = c % mod i ++ if i == length { return b , nil } } } }
randomBytesMod returns a byte slice of the given length, where each byte is
a random number modulo mod.
randomBytesMod returns a byte slice of the given length where each byte is a random number modulo mod .
// Skip this number to avoid modulo bias.