@Test public void testCreateMasterKeyWithSalt() throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException { long timeStart = System.currentTimeMillis(); SaltedSecretKey masterKeyForPasswordTestAndSalt123 = CipherUtil.createMasterKey("Test", new byte[] {1, 2, 3}); long timeEnd = System.currentTimeMillis(); long timeDuration = timeEnd - timeStart; logger.log(Level.INFO, "Creating master key took " + timeDuration + "ms:"); logger.log( Level.INFO, " - Key: " + StringUtil.toHex(masterKeyForPasswordTestAndSalt123.getEncoded())); logger.log( Level.INFO, " - Salt: " + StringUtil.toHex(masterKeyForPasswordTestAndSalt123.getSalt())); assertEquals("010203", StringUtil.toHex(masterKeyForPasswordTestAndSalt123.getSalt())); assertEquals( "44fda24d53b29828b62c362529bd9df5c8a92c2736bcae3a28b3d7b44488e36e246106aa5334813028abb2048eeb5e177df1c702d93cf82aeb7b6d59a8534ff0", StringUtil.toHex(masterKeyForPasswordTestAndSalt123.getEncoded())); assertEquals( CipherUtil.MASTER_KEY_SIZE / 8, masterKeyForPasswordTestAndSalt123.getEncoded().length); assertEquals("PBKDF2WithHmacSHA1", masterKeyForPasswordTestAndSalt123.getAlgorithm()); assertEquals("RAW", masterKeyForPasswordTestAndSalt123.getFormat()); assertTrue(timeDuration > 5000); }