code: public static String encodeStringInBase64(String str, Charset charset) {
          return new String(Base64.encodeBase64(str.getBytes(charset)));
      }
docs: Encodes a string to base64.
  
  @param str     The string value to encode.
  @param charset The encoding charset used to obtain the byte sequence of the string.
  @return The encoded byte sequence using the base64 encoding.