// BytesToHex transfer binary to hex bytes
504419
func Bytes2Hex(src []byte) []byte {
	dst := make([]byte, 2*len(src))
	hex.Encode(dst, src)

	return dst
}
596074
func (e *ErrorV1) Bytes() []byte {
	if bs, err := json.MarshalIndent(e, "", "  "); err == nil {
		return bs
	}
	return nil
}
1015243
func binaryEncodeToString(src []byte) string {
	dst := make([]byte, len(src)*8)
	encodeBinary(dst, src)
	return string(dst)
}
284302
func BytesToJSON(b *[]byte) (*interface{}, error) {
	var container interface{}
	err := json.Unmarshal(*b, &container)

	if err != nil {
		return nil, err
	}

	return &container, nil
}
938926
func colonSeparatedHex(data []byte) string {
	sshKeyFingerprint := fmt.Sprintf("%x", data)
	var colonSeparated bytes.Buffer
	for i := 0; i < len(sshKeyFingerprint); i++ {
		if (i%2) == 0 && i != 0 {
			colonSeparated.WriteByte(':')
		}
		colonSeparated.WriteByte(sshKeyFingerprint[i])
	}

	return colonSeparated.String()
}
471234
func (f *Feed) Hex() string {
	serializedData := make([]byte, feedLength)
	f.binaryPut(serializedData)
	return hexutil.Encode(serializedData)
}
695902
func RandomHex(n int) (string, error) {
	bytes := make([]byte, n)
	if _, err := rand.Read(bytes); err != nil {
		return "", err
	}
	return hex.EncodeToString(bytes), nil
}
951262
func (e *Event) Hex(key string, val []byte) *Event {
	if e == nil {
		return e
	}
	e.buf = enc.AppendHex(enc.AppendKey(e.buf, key), val)
	return e
}
179840
func messageToHex(msg wire.Message) (string, error) {
	var buf bytes.Buffer
	if err := msg.BtcEncode(&buf, maxProtocolVersion, wire.WitnessEncoding); err != nil {
		context := fmt.Sprintf("Failed to encode msg of type %T", msg)
		return "", internalRPCError(err.Error(), context)
	}

	return hex.EncodeToString(buf.Bytes()), nil
}
60722
func (t Tag) Hex() string {
	bin := make([]byte, 2, 2)
	binary.BigEndian.PutUint16(bin, uint16(t))
	return hex.EncodeToString(bin)
}
203799
func (i Uint64Key) Bytes() []byte {
	buf := make([]byte, 8)
	binary.BigEndian.PutUint64(buf, uint64(i))
	return buf
}
922361
func isHex(str string) bool {
	if len(str)%2 != 0 {
		return false
	}
	for _, c := range []byte(str) {
		if !isHexCharacter(c) {
			return false
		}
	}
	return true
}
1167248
func RandomHex(count int) ([]byte, error) {
	raw := make([]byte, count)
	_, err := rand.Read(raw)
	if err != nil {
		log.Errorf("RandomBytes(): Error %s", err.Error())
		return nil, err
	}

	encoded := make([]byte, count*2)
	hex.Encode(encoded, raw)
	return encoded, nil
}
621125
func (r *Rx) Bytes() (tx, rx []byte) {
	return r.tx.Bytes(), r.rx.Bytes()
}
1326614
func (p *parserMixin) HexBytes() (target *[]byte) {
	target = new([]byte)
	p.HexBytesVar(target)
	return
}
286426
func toHex(l yyLexer, lval *yySymType, str string) int {
	h, err := types.ParseHex(str)
	if err != nil {
		// If parse hexadecimal literal to numerical value error, we should treat it as a string.
		hexStr, err1 := types.ParseHexStr(str)
		if err1 != nil {
			l.Errorf("hex literal: %v", err)
			return int(unicode.ReplacementChar)
		}
		lval.item = hexStr
		return hexLit
	}
	lval.item = h
	return hexLit
}
227165
func (x FixInt) Bytes() []byte {
	b := []byte{0, 0, 0, 0, 0, 0, 0, 0}
	y := int64(x)
	b[0] = byte((y >> 56) & 0xFF)
	b[1] = byte((y >> 48) & 0xFF)
	b[2] = byte((y >> 40) & 0xFF)
	b[3] = byte((y >> 32) & 0xFF)
	b[4] = byte((y >> 24) & 0xFF)
	b[5] = byte((y >> 16) & 0xFF)
	b[6] = byte((y >> 8) & 0xFF)
	b[7] = byte(y & 0xFF)
	return b
}