use hasHexPrefix for 0x prefix check

This commit is contained in:
lmittmann 2019-08-15 12:40:58 +02:00
parent d9258162ca
commit 5b2834856e

View file

@ -43,10 +43,8 @@ func ToHexArray(b [][]byte) []string {
// FromHex returns the bytes represented by the hexadecimal string s.
// s may be prefixed with "0x".
func FromHex(s string) []byte {
if len(s) > 1 {
if s[0:2] == "0x" || s[0:2] == "0X" {
s = s[2:]
}
if hasHexPrefix(s) {
s = s[2:]
}
if len(s)%2 == 1 {
s = "0" + s