Java z-base-32 encoding algorithm

3.5k views Asked by At

I'm searching for an implementation of z-base-32 enc algo in java, any suggestions? (encoding and decoding)

2

There are 2 answers

2
Björn On BEST ANSWER

Ok, I felt I had to give this a shot. I translated the C# implementation from My Ten Pennies to Java, and an example and source an be downloaded from here. It's not especially good looking code, but hey - it hopefully does it's work.

I haven't had time to test it thoroughly, but my short tests work fine.

Usage:

import se.welcomweb.utils.zbase32j;

public class TestZBase32J {

    public static void main(String ... args) {

        ZBase32j zbase = new ZBase32j();

        String message = "Hello, world!";
        String encoded = zbase.encode(message);
        System.out.println("Encoded: " + encoded);

        String decoded = zbase.decode(encoded);
        System.out.println("Decoded: " + decoded);

    }

}
0
ZZ Coder On

I didn't compare but it looks like the Base32 we use here. Here is the original code,

http://svn.savannah.gnu.org/svn/ccrtp/tags/release-ccrtp-1.7.0/contributions/ZRTP4J/src/gnu/java/zrtp/utils/Base32.java