Android examples for java.security:AES
decode AES Key
//package com.java2s; import android.util.Base64; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; import java.io.*; public class Main { public static String decodeKey(String key) throws Exception { SecretKeySpec skeySpec = new SecretKeySpec(getCryptoStringKey(), "AES"); Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); cipher.init(Cipher.DECRYPT_MODE, skeySpec); byte[] keyBytes = Base64.decode(key, Base64.DEFAULT); return new String(cipher.doFinal(keyBytes), "UTF-8"); }// w w w .jav a 2 s. co m private static byte[] getCryptoStringKey() { // byte[] key = new byte[16]; try { return ("d12Vp54R4sb0ymVF").getBytes("UTF-8"); } catch (UnsupportedEncodingException x) { throw new RuntimeException(x); } } }