A naive implementation for this would be:
static String[] baseMap = 'YBNDRFG8EJKMCPQXOT1UWISZA345H769'.split('');
public String encodeZbase32(Integer source) {
return
baseMap[(source >> 25)&31] +
baseMap[(source >> 20)&31] +
baseMap[(source >> 15)&31] +
baseMap[(source >> 10)&31] +
baseMap[(source >> 5)&31] +
baseMap[(source )&31];
}
public Integer decodeZBase32(String source) {
String[] bits = source.split('');
return
(baseMap.indexOf(bits))<<25 |
(baseMap.indexOf(bits))<<20 |
(baseMap.indexOf(bits))<<15 |
(baseMap.indexOf(bits))<<10 |
(baseMap.indexOf(bits))<< 5 |
(baseMap.indexOf(bits));
}
I leave it up to you to decide if you need the trailing 0 bits at the end, or any other features.