forked from urdt/ussd
19 lines
254 B
Go
19 lines
254 B
Go
|
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
|
||
|
}
|