### Question:
CryptoUtil { public static String getSaltedPassword( byte[] password ) throws NoSuchAlgorithmException { byte[] salt = new byte[DEFAULT_SALT_SIZE]; RANDOM.nextBytes( salt ); return getSaltedPassword( password, salt ); } private  CryptoUtil(); static void main( final String[] args ); static String getSaltedPassword( byte[] password ); static boolean verifySaltedPassword( byte[] password, String entry );  }### Answer:
@Test public void testGetSaltedPassword() throws Exception { byte[] password; password = "testing123".getBytes(); Assertions.assertEquals( "{SSHA}yfT8SRT/WoOuNuA6KbJeF10OznZmb28=", CryptoUtil.getSaltedPassword( password, "foo".getBytes() ) ); password = "password".getBytes(); Assertions.assertEquals( "{SSHA}tAVisOOQGAeVyP8UMFQY9qi83lxsb09e", CryptoUtil.getSaltedPassword( password, "loO^".getBytes() ) ); Assertions.assertEquals( "{SSHA}BZaDYvB8czmNW3MjR2j7/mklODV0ZXN0eQ==", CryptoUtil.getSaltedPassword( password, "testy".getBytes() ) ); }
@Test public void testMultipleHashes() throws Exception { String p1 = CryptoUtil.getSaltedPassword( "password".getBytes() ); String p2 = CryptoUtil.getSaltedPassword( "password".getBytes() ); String p3 = CryptoUtil.getSaltedPassword( "password".getBytes() ); Assertions.assertNotSame( p1, p2 ); Assertions.assertNotSame( p2, p3 ); Assertions.assertNotSame( p1, p3 ); }
@Test public void testSaltedPasswordLength() throws Exception { byte[] password = "mySooperRandomPassword".getBytes(); String hash = CryptoUtil.getSaltedPassword( password, "salt".getBytes() ); Assertions.assertEquals( 38, hash.length() ); }