Class Base32

java.lang.Object
com.codename1.security.Base32

public final class Base32 extends java.lang.Object

Base32 encoder/decoder per RFC 4648. Mostly useful for OTP shared secrets, which are conventionally distributed as Base32 strings (the format embedded in QR codes by authenticator apps).

Example
byte[] secret = Base32.decode("JBSWY3DPEHPK3PXP");
String enc    = Base32.encode(secret);
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    Decodes a Base32 string.
    static String
    encode(byte[] data)
    Encodes the bytes as a Base32 string (uppercase, with = padding).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • encode

      public static String encode(byte[] data)
      Encodes the bytes as a Base32 string (uppercase, with = padding).
    • decode

      public static byte[] decode(String s)
      Decodes a Base32 string. Padding and whitespace are tolerated; mixed case is accepted.