Class B64

java.lang.Object
org.apache.commons.codec.digest.B64

class B64 extends Object
Base64-like method to convert binary bytes into ASCII chars.

TODO: Can Base64 be reused?

This class is immutable and thread-safe.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final char[]
    Table with characters for Base64 transformation.
    (package private) static final String
    Table with characters for Base64 transformation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    B64()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static void
    b64from24bit(byte b2, byte b1, byte b0, int outLen, StringBuilder buffer)
    Base64 like conversion of bytes to ASCII chars.
    (package private) static String
    getRandomSalt(int num)
    Generates a string of random chars from the B64T set.
    (package private) static String
    getRandomSalt(int num, Random random)
    Generates a string of random chars from the B64T set.

    Methods inherited from class java.lang.Object

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

    • B64T_STRING

      static final String B64T_STRING
      Table with characters for Base64 transformation.
      See Also:
    • B64T_ARRAY

      static final char[] B64T_ARRAY
      Table with characters for Base64 transformation.
  • Constructor Details

    • B64

      B64()
  • Method Details

    • b64from24bit

      static void b64from24bit(byte b2, byte b1, byte b0, int outLen, StringBuilder buffer)
      Base64 like conversion of bytes to ASCII chars.
      Parameters:
      b2 - A byte from the result.
      b1 - A byte from the result.
      b0 - A byte from the result.
      outLen - The number of expected output chars.
      buffer - Where the output chars is appended to.
    • getRandomSalt

      static String getRandomSalt(int num)
      Generates a string of random chars from the B64T set.

      The salt is generated with SecureRandom.

      Parameters:
      num - Number of chars to generate.
      Returns:
      a random salt String.
    • getRandomSalt

      static String getRandomSalt(int num, Random random)
      Generates a string of random chars from the B64T set.

      The salt is generated with the Random provided.

      Parameters:
      num - Number of chars to generate.
      random - an instance of Random.
      Returns:
      a random salt String.