@Test public void generateSaltTest() { byte[][] salt = new byte[100][]; for (int i = 0; i < salt.length; i++) { salt[i] = PasswordUtil.generateRandomSalt(); assertNotNull(salt[i]); assertTrue(salt[i].length == PasswordUtil.SALT_BIT_SIZE / 8); logger.debug("Generated Salt: {}.", EncryptionUtil.byteToHex(salt[i])); for (int j = 0; j < i; j++) { assertFalse(Arrays.equals(salt[i], salt[j])); } } }
public static byte[] generateRandomSalt() { SecureRandom random = new SecureRandom(); byte[] salt = new byte[SALT_BIT_SIZE / 8]; random.nextBytes(salt); return salt; }
PasswordUtil { public static byte[] generateRandomSalt() { SecureRandom random = new SecureRandom(); byte[] salt = new byte[SALT_BIT_SIZE / 8]; random.nextBytes(salt); return salt; } }
PasswordUtil { public static byte[] generateRandomSalt() { SecureRandom random = new SecureRandom(); byte[] salt = new byte[SALT_BIT_SIZE / 8]; random.nextBytes(salt); return salt; } private  PasswordUtil(); }
PasswordUtil { public static byte[] generateRandomSalt() { SecureRandom random = new SecureRandom(); byte[] salt = new byte[SALT_BIT_SIZE / 8]; random.nextBytes(salt); return salt; } private  PasswordUtil(); static byte[] generateRandomSalt(); static byte[] generateFixedSalt(byte[] input); static byte[] generateHash(char[] password, byte[] salt); static SecretKey generateAESKeyFromPassword(String password, String pin, AES_KEYLENGTH keyLength); static boolean validatePassword(char[] password, byte[] salt, byte[] correctHash); }
PasswordUtil { public static byte[] generateRandomSalt() { SecureRandom random = new SecureRandom(); byte[] salt = new byte[SALT_BIT_SIZE / 8]; random.nextBytes(salt); return salt; } private  PasswordUtil(); static byte[] generateRandomSalt(); static byte[] generateFixedSalt(byte[] input); static byte[] generateHash(char[] password, byte[] salt); static SecretKey generateAESKeyFromPassword(String password, String pin, AES_KEYLENGTH keyLength); static boolean validatePassword(char[] password, byte[] salt, byte[] correctHash); static final int HASH_BIT_SIZE; static final int SALT_BIT_SIZE; }