|
|
|
@ -4,6 +4,7 @@ import ( |
|
|
|
|
"bytes" |
|
|
|
|
"encoding/hex" |
|
|
|
|
"strings" |
|
|
|
|
_"fmt" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func CompactEncode(hexSlice []int) string { |
|
|
|
@ -32,6 +33,21 @@ func CompactEncode(hexSlice []int) string { |
|
|
|
|
return buff.String() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func CompactDecode(str string) []int { |
|
|
|
|
base := CompactHexDecode(str) |
|
|
|
|
base = base[:len(base)-1] |
|
|
|
|
if base[0] >= 2 {// && base[len(base)-1] != 16 {
|
|
|
|
|
base = append(base, 16) |
|
|
|
|
} |
|
|
|
|
if base[0] % 2 == 1 { |
|
|
|
|
base = base[1:] |
|
|
|
|
} else { |
|
|
|
|
base = base[2:] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return base |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func CompactHexDecode(str string) []int { |
|
|
|
|
base := "0123456789abcdef" |
|
|
|
|
hexSlice := make([]int, 0) |
|
|
|
|