Java tutorial
//package com.java2s; import android.util.Base64; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; public class Main { public static String encode(String plain) { return encode(plain, StandardCharsets.UTF_8); } public static String encode(String plain, Charset charset) { return Base64.encodeToString(plain.getBytes(charset), Base64.DEFAULT); } }