Android examples for java.security:AES
generate AES Key from key String
//package com.java2s; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import android.util.Log; public class Main { public static final String AES = "AES"; public static SecretKey geneKey(String key) throws NoSuchAlgorithmException { final int outputKeyLength = 256; SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); Log.i("sr", "secureRandom:" + secureRandom.getProvider().getInfo()); secureRandom.setSeed(key.getBytes()); KeyGenerator keyGenerator = KeyGenerator.getInstance(AES); keyGenerator.init(outputKeyLength, secureRandom); SecretKey seckey = keyGenerator.generateKey(); return seckey; }/*from ww w. j a va 2s .co m*/ }