Skip to content
Advertisement

org.apache.commons.codec.binary.Base32 decodes to same byte array for different strings

I have a encoded String and trying to decode it. But I am getting the same byte[] when I added zeros into it.

String val = "VU4ACWPU52WWBTKV4PLCC6BQPA5E7ZLYITGR4NLIZKYZKPPZU2SPZYQPECFA6SCIOYQTU4P4XFERESTTXUSOM4BBZYARDBKHDIGZFPWQ";

Base32 base32 = new Base32(0);

base32.decode(val);
base32.decode("000"+ val);

Both the decodes above returns the same byte array. Can anyone help me understand whys is it same when I added some zeros to it? Thanks.

Advertisement

Answer

Look here:

https://guava.dev/releases/16.0/api/docs/com/google/common/io/BaseEncoding.html

You can see that base32 is using A-Z and 2-7 as encoding. Zeros will not change anything.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement