import sun.misc.BASE64Encoder;
import sun.misc.BASE64Decoder;
public class Base64encoder {
public static void main(String[] args) throws Exception {
BASE64Encoder encoder = new BASE64Encoder();
String username = "zsz19901116@163.com";
String password = "674515zsz";
String a = encoder.encode(username.getBytes());
String b = encoder.encode(password.getBytes());
System.out.println(a + "\n" + b);
BASE64Decoder decoder = new BASE64Decoder();
String c = a;
String d = b;
String e = new String(decoder.decodeBuffer(c));
String f = new String(decoder.decodeBuffer(d));
System.out.println(e + "\n" + f);
}
}
原文:http://www.cnblogs.com/zszitman/p/4433472.html