Here you can find the source of encrypt(String data)
public static String encrypt(String data)
//package com.java2s; import java.security.SecureRandom; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.spec.SecretKeySpec; import android.util.Base64; public class Main { private static final String seed = "This is a secret"; public static String encrypt(String data) { try {//from w ww. j a v a 2 s . co m SecretKeySpec sks = null; byte[] encodedBytes = null; SecureRandom sr = SecureRandom.getInstance("SHA1PRNG"); sr.setSeed(seed.getBytes()); KeyGenerator kg = KeyGenerator.getInstance("AES"); kg.init(128, sr); sks = new SecretKeySpec((kg.generateKey()).getEncoded(), "AES"); Cipher c = Cipher.getInstance("AES"); c.init(Cipher.ENCRYPT_MODE, sks); encodedBytes = c.doFinal(data.getBytes()); return Base64.encodeToString(encodedBytes, Base64.DEFAULT); } catch (Exception e) { } return null; } }