private static Cipher createCipher ( final String algorithm , final int mode , final char [ ] password , final byte [ ] salt , final int count ) throws GeneralSecurityException { final SecretKeyFactory keyFactory = SecretKeyFactory . getInstance ( algorithm ) ; final PBEKeySpec keySpec = new PBEKeySpec ( password ) ; final SecretKey key = keyFactory . generateSecret ( keySpec ) ; final Cipher cipher = Cipher . getInstance ( algorithm ) ; final PBEParameterSpec params = new PBEParameterSpec ( salt , count ) ; cipher . init ( mode , key , params ) ; return cipher ; }
Creates a cipher for encryption or decryption .