ussd/common/hex.go

19 lines
254 B
Go
Raw Permalink Normal View History

2024-10-30 01:59:59 +01:00
package common
import (
"encoding/hex"
)
func NormalizeHex(s string) (string, error) {
if len(s) >= 2 {
if s[:2] == "0x" {
s = s[2:]
}
}
r, err := hex.DecodeString(s)
if err != nil {
return "", err
}
return hex.EncodeToString(r), nil
}