Here you can find the source of decrypt(String data, String key)
public static String decrypt(String data, String key) throws Exception
//package com.java2s; import java.security.SecureRandom; import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import android.util.Base64; public class Main { private static final String CIPHER_ALGORITHM = "AES"; private static final String RANDOM_GENERATOR_TYPE = "SHA1PRNG"; private static final int RANDOM_KEY_SIZE = 128; public static String decrypt(String data, String key) throws Exception { byte[] myKey = generateKey(key.getBytes()); // Grab secret key SecretKeySpec spec = new SecretKeySpec(myKey, CIPHER_ALGORITHM); Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); cipher.init(Cipher.DECRYPT_MODE, spec); // Decrypt data byte[] encryptedData = Base64.decode(data, Base64.DEFAULT); byte[] decryptedData = cipher.doFinal(encryptedData); // Convert to string String result = new String(decryptedData); return result; }// w ww . j ava2 s . co m public static byte[] generateKey(byte[] randomSeed) throws Exception { // Set up generators KeyGenerator gen = KeyGenerator.getInstance(CIPHER_ALGORITHM); SecureRandom rand = SecureRandom.getInstance(RANDOM_GENERATOR_TYPE); rand.setSeed(randomSeed); // Generate key gen.init(RANDOM_KEY_SIZE, rand); SecretKey myKey = gen.generateKey(); return myKey.getEncoded(); } }