Java
Chilkat2 Java
Base64 Encode/Decode a String
See more Encryption Examples
_LANGUAGE_ example to base-64 encode and decode a string.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.BinData;
public class ChilkatExample {
public static void main(String[] args) {
BinData bd = new BinData();
String s = "A friend called me up the other day and talked about investing in a dot-com that sells lobsters. Internet lobsters. Where will this end? --Donald Trump";
bd.appendString(s, "utf-8");
String strBase64 = bd.getEncoded("base64");
System.out.println(strBase64);
// To decode:
BinData bd2 = new BinData();
bd2.appendEncoded(strBase64, "base64");
String decoded = bd2.getString("utf-8");
System.out.println(decoded);
}
}