Java tutorial
//package com.java2s; import android.text.TextUtils; import org.apache.commons.codec.binary.Base64; public class Main { private static Base64 mBase64 = new Base64(); /** * encode * @param source source * @return String */ public static String encode(String source) { if (!TextUtils.isEmpty(source)) { return new String(mBase64.encode(source.getBytes())); } return ""; } }