public static byte [ ] encryptPasswordBased ( final String algorithm , final byte [ ] data , final char [ ] password , final byte [ ] salt , final int count ) { checkNotNull ( "algorithm" , algorithm ) ; checkNotNull ( "data" , data ) ; checkNotNull ( "password" , password ) ; checkNotNull ( "salt" , salt ) ; try { final Cipher cipher = createCipher ( algorithm , Cipher . ENCRYPT_MODE , password , salt , count ) ; return cipher . doFinal ( data ) ; } catch ( final Exception ex ) { throw new RuntimeException ( "Error encrypting the password!" , ex ) ; } }
Encrypts some data based on a password .