I want to convert a big.Int
to simple base32. Not the standard base32 stuff like the RFC 4648 implemented by base32
nor zBase32 nor Crockford I want just simple normal 5-bits per character 0-9A-V character set.
I am aware of the base32
package and it does not do what I want - it builds the result in a standard base 32 number with padding and stuff I don't want. Certainly I could use it and tear off the trailing "=" characters and hack what remains but that just seems like a brutal solution.
There is a big.SetString(string, base)
that can parse a base32 number in string form but there is no reverse - which is what I am really looking for, a big.GetString(base)
like the Java BigInteger.toString(int base)
.
There is, however, a nat.string
which does exactly what I want. How can I gain access to it?
Is there a way I could manually extend big
to implement big.GetString(base)
which trivially calls nat.string
with the correct charset
?
Is there a way I can reach into the unexported big.nat
which big
uses and call nat.string
?
Is there something else I can do?
P.S. I'd also be interested in using nat.trailingZeroBits
- I had to write my own because I didn't realise this was already done.