Package org.kissweb

Class Base64

java.lang.Object
org.kissweb.Base64

public class Base64 extends Object
Utility methods to deal with Base64. Author: Blake McBride Date: 11/2/23
  • Constructor Details

    • Base64

      public Base64()
  • Method Details

    • encode

      public static String encode(byte[] ba)
      Base64 encode
      Parameters:
      ba - the byte array to be converted to a base64 string
      Returns:
      the base64 string representation of a byte array
    • decode

      public static byte[] decode(String s) throws IOException
      Base 64 decode
      Parameters:
      s - the base64 encoded string
      Returns:
      the decoded byte array
      Throws:
      IOException
    • mightBeBase64

      public static boolean mightBeBase64(String value)
      Checks if a given string is a valid Base64 string. If true is returned, it does not guarantee that the input string is a base64 string. It only guarantees that it is a valid base64 string.

      For example: isBase64("find") == true because is can be interpreted as a base64 but isn't intended to be a base64 string.

      So, this method does not tell you if a string is a base64 string. It merely tells you if it can be interpreted as a base64 string.
      Parameters:
      value - the string to be checked
      Returns:
      true if the string is a valid Base64 string, false otherwise
    • mightBeBinary

      public static boolean mightBeBinary(String content)
      Determines whether the given content might be binary.
      Parameters:
      content - the content to be checked
      Returns:
      true if the content might be binary, false if it's likely to be text