// RandomBytes generates some random bytes
425954
func RandomBytes(length int) (string, error) {
	b := make([]byte, length)
	_, err := crypto_rand.Read(b)
	if err != nil {
		return "", err
	}

	return hex.EncodeToString(b), nil
}
971467
func (c *Client) Random(args []string) (Random, error) {
	argsStr := strings.Join(args, " ")

	req, err := c.NewRequest("/gifs/random?tag=" + argsStr)
	if err != nil {
		return Random{}, err
	}

	var random Random
	if _, err = c.Do(req, &random); err != nil {
		return Random{}, err
	}

	// Check if the first character in Data is a [
	if random.RawData == nil || random.RawData[0] == '[' {
		return Random{}, ErrNoImageFound
	}

	var d RandomData

	err = json.Unmarshal(random.RawData, &d)
	if err != nil {
		return Random{}, err
	}

	random.Data = d

	return random, nil
}
1179376
func RandomBytes(count int) []byte {
	b := make([]byte, count)
	crand.Read(b)
	return b
}
740861
func randbytes(n int) []byte {
	buf := make([]byte, n)
	if _, err := rand.Read(buf); err != nil {
		panic(fmt.Sprintf("failed to generate %d random bytes: %v", n, err))
	}
	return buf
}
661900
func (c *Config) EncryptBytes() ([]byte, error) {
	return base64.StdEncoding.DecodeString(c.EncryptKey)
}
70396
func Bytes(length int) []byte {
	out := make([]byte, length)
	if _, err := io.ReadFull(rand.Reader, out); err != nil {
		panic(err)
	}
	return out
}
1007230
func readBytes(r io.Reader) ([]byte, error) {
	length, err := readInt32(r)
	if err != nil {
		return nil, err
	}
	buf := make([]byte, length)
	_, err = io.ReadFull(r, buf)
	if err != nil {
		return nil, err
	}
	return buf, nil
}
687186
func (b *builderBuffer) WriteBytes(v byte, count uint) {
	if count == 0 {
		return
	}
	off := uint(len(*b))
	b.growCapacity(count)
	*b = (*b)[:off+count]
	for i := uint(0); i < count; i++ {
		(*b)[off+i] = v
	}
}
1358458
func RandomBytes(n int) []byte {
	key := make([]byte, n)
	_, err := io.ReadFull(rand.Reader, key)
	if err != nil {
		log.Panicf("auth: could not generate random bytes: %s", err)
	}
	return key
}
1263444
func WriteBytes(buf io.ByteWriter, data []byte) (n int, err error) {
	wb := func(b byte) (err error) {
		if err = buf.WriteByte(b); err == nil {
			n++
		}
		return
	}

	acc := byte(0)
	for i := 0; i < len(data); i++ {
		m := uint(i % 7)
		b := data[i]
		if err = wb(acc | 1 | ((b & (0xff << (m + 1))) >> m)); err != nil {
			return
		}
		acc = (b << (7 - m))
		if m == 6 {
			if err = wb(acc | 1); err != nil {
				return
			}
			acc = 0
		}
	}
	err = wb(acc)
	return
}
961786
func RandToken(size int) string {
	buf := make([]byte, size)
	if n, err := rand.Read(buf); err != nil || n != len(buf) {
		panic("failed to get random: " + err.Error())
	}
	return fmt.Sprintf("%x", buf)
}
728706
func GetRandomBytes(len int) ([]byte, error) {
	key := make([]byte, len)

	// TODO: rand could fill less bytes then len
	_, err := rand.Read(key)
	if err != nil {
		return nil, errors.Wrap(err, "error getting random bytes")
	}

	return key, nil
}
347905
func uint64ToBytes(n uint64) []byte {
	return []byte{
		byte(n),
		byte(n >> 8),
		byte(n >> 16),
		byte(n >> 24),
		byte(n >> 32),
		byte(n >> 40),
		byte(n >> 48),
		byte(n >> 56),
	}
}
1306005
func (b *BigIP) UploadBytes(data []byte, filename string) (*Upload, error) {
	r := bytes.NewReader(data)
	size := int64(len(data))
	return b.Upload(r, size, uriShared, uriFileTransfer, uriUploads, filename)
}
1023498
func (s *stream) readBytes(n uint32) ([]byte, error) {
	if n > s.size {
		s.buf = make([]byte, n)
		s.size = n
	}

	if _, err := io.ReadFull(s.Reader, s.buf[:n]); err != nil {
		return nil, err
	}

	return s.buf[:n], nil
}
1020299
func (r *myRnd) NextByte() byte {
	r.seed1 = (r.seed1*3 + r.seed2) % myRndMaxVal
	r.seed2 = (r.seed1 + r.seed2 + 33) % myRndMaxVal

	return byte(uint64(r.seed1) * 31 / myRndMaxVal)
}
730476
func PackBytes(cmd BufferEx, b []byte) (int, error) {
	return packBytes(cmd, b)
}