Java tutorial
//package com.java2s; import android.util.Base64; public class Main { /** * function encrypt the string and return the result * @param stringToEncrypt the string against which the encryption to be performed * @return the encrypted String */ public static final String encrypt(String stringToEncrypt) { try { byte[] data = stringToEncrypt.getBytes("UTF-8"); String base64 = Base64.encodeToString(data, Base64.DEFAULT); return base64; } catch (Exception e) { e.printStackTrace(); } return stringToEncrypt; // try { // Key aesKey = new SecretKeySpec(key.getBytes(), "AES"); // Cipher cipher = Cipher.getInstance("AES"); // cipher.init(Cipher.ENCRYPT_MODE, aesKey); // byte[] encrypted = cipher.doFinal(stringToEncrypt.getBytes()); // return new String(encrypted); // }catch (Exception e){ // // } // return null; } }