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

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