arnaucube
arnaucube/cryptofunPublic Self-hosted repository
cryptofun/utils/utils.go
utils/utils.goRaw
 1package utils
 2
 3import "encoding/hex"
 4
 5// BytesToHex converts from an array of bytes to a hex encoded string
 6func BytesToHex(bytesArray []byte) string {
 7	r := "0x"
 8	h := hex.EncodeToString(bytesArray)
 9	r = r + h
10	return r
11}
12
13// HexToBytes converts from a hex string into an array of bytes
14func HexToBytes(h string) ([]byte, error) {
15	b, err := hex.DecodeString(h[2:])
16	return b, err
17}