Java examples for Security:AES
generate AES Key
//package com.java2s; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; public class Main { private static final String KEY_ALGORITHM = "AES"; static SecretKey generateKey2(String pwd) { SecretKeySpec secretKeySpec = null; try {/*from w ww .j a v a 2 s .co m*/ secretKeySpec = new SecretKeySpec(MessageDigest.getInstance( "MD5").digest(pwd.getBytes()), KEY_ALGORITHM); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } return secretKeySpec; } }