private SecretKey getSecretKey ( char [ ] key ) throws NoSuchAlgorithmException , UnsupportedEncodingException , InvalidKeySpecException { SecretKeyFactory factory = SecretKeyFactory . getInstance ( mBuilder . getSecretKeyType ( ) ) ; KeySpec spec = new PBEKeySpec ( key , mBuilder . getSalt ( ) . getBytes ( mBuilder . getCharsetName ( ) ) , mBuilder . getIterationCount ( ) , mBuilder . getKeyLength ( ) ) ; SecretKey tmp = factory . generateSecret ( spec ) ; return new SecretKeySpec ( tmp . getEncoded ( ) , mBuilder . getKeyAlgorithm ( ) ) ; }
creates a 128bit salted aes key