private SecretKey generateAESKey ( String privateKey , String salt ) { try { byte [ ] raw = decodeHex ( salt ) ; KeySpec spec = new PBEKeySpec ( privateKey . toCharArray ( ) , raw , iterationCount , keySize ) ; SecretKeyFactory factory = SecretKeyFactory . getInstance ( PBKDF_2_WITH_HMAC_SHA_1 ) ; return new SecretKeySpec ( factory . generateSecret ( spec ) . getEncoded ( ) , AES_ECB_ALGORITHM ) ; } catch ( NoSuchAlgorithmException | InvalidKeySpecException e ) { throw new IllegalStateException ( e ) ; } }
Generate the AES key from the salt and the private key .