Android examples for java.security:Key
decrypt String by Secret Key
//package com.java2s; import android.util.Base64; import javax.crypto.Cipher; import javax.crypto.SecretKey; public class Main { public static String decryptString(String encryptedString, SecretKey key) { String decryptedString = null; byte[] decodedBytes = null; try {/*from w ww.j av a 2 s . co m*/ Cipher c = Cipher.getInstance("AES"); c.init(Cipher.DECRYPT_MODE, key); byte[] myBytes = Base64.decode(encryptedString, Base64.DEFAULT); decodedBytes = c.doFinal(myBytes); decryptedString = new String(decodedBytes); } catch (Exception e) { } return decryptedString; } }