Move base16 and base32 specific bits to their own file.

This commit is contained in:
Kevin Atkinson
2017-08-28 21:32:26 -04:00
parent e81eb6473b
commit 36e6b228ae
3 changed files with 38 additions and 33 deletions

21
base16.go Normal file
View File

@@ -0,0 +1,21 @@
package multibase
func hexEncodeToStringUpper(src []byte) string {
dst := make([]byte, len(src)*2)
hexEncodeUpper(dst, src)
return string(dst)
}
var hextableUpper = [16]byte{
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F',
}
func hexEncodeUpper(dst, src []byte) int {
for i, v := range src {
dst[i*2] = hextableUpper[v>>4]
dst[i*2+1] = hextableUpper[v&0x0f]
}
return len(src) * 2
}