You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
384 B

package utils
import "encoding/hex"
// BytesToHex converts from an array of bytes to a hex encoded string
func BytesToHex(bytesArray []byte) string {
r := "0x"
h := hex.EncodeToString(bytesArray)
r = r + h
return r
}
// HexToBytes converts from a hex string into an array of bytes
func HexToBytes(h string) ([]byte, error) {
b, err := hex.DecodeString(h[2:])
return b, err
}