code: private String base64(String value)
      {
          StringBuffer cb = new StringBuffer();
  
          int i = 0;
          for (i = 0; i + 2 < value.length(); i += 3) {
              long chunk = (int) value.charAt(i);
              chunk = (chunk << 8) + (int) value.charAt(i + 1);
              chunk = (chunk << 8) + (int) value.charAt(i + 2);
  
              cb.append(encode(chunk >> 18));
              cb.append(encode(chunk >> 12));
              cb.append(encode(chunk >> 6));
              cb.append(encode(chunk));
          }
  
          if (i + 1 < value.length()) {
              long chunk = (int) value.charAt(i);
              chunk = (chunk << 8) + (int) value.charAt(i + 1);
              chunk <<= 8;
  
              cb.append(encode(chunk >> 18));
              cb.append(encode(chunk >> 12));
              cb.append(encode(chunk >> 6));
              cb.append('=');
          }
          else if (i < value.length()) {
              long chunk = (int) value.charAt(i);
              chunk <<= 16;
  
              cb.append(encode(chunk >> 18));
              cb.append(encode(chunk >> 12));
              cb.append('=');
              cb.append('=');
          }
  
          return cb.toString();
      }
docs: Creates the Base64 value.