@Test public void testDuplication() throws NoSuchAlgorithmException, InvalidKeySpecException { Set<String> passwordHashes = new HashSet<>(20); for (int i = 0; i < 10; i++) { String passwordHash = PasswordHash.createHash("p\r\nassw0Rd!"); Assert.assertFalse("PasswordHash duplication occurs", passwordHashes.contains(passwordHash)); passwordHashes.add(passwordHash); } }
public static String createHash(String password) { Args.notBlank(password, "password"); return createHash(StringUtil.toUtf8Bytes(password)); }
PasswordHash { public static String createHash(String password) { Args.notBlank(password, "password"); return createHash(StringUtil.toUtf8Bytes(password)); } }
PasswordHash { public static String createHash(String password) { Args.notBlank(password, "password"); return createHash(StringUtil.toUtf8Bytes(password)); } private  PasswordHash(); }
PasswordHash { public static String createHash(String password) { Args.notBlank(password, "password"); return createHash(StringUtil.toUtf8Bytes(password)); } private  PasswordHash(); static String createHash(String password); static String createHash(byte[] password); static String createHash(byte[] password, int saltSize, int iterations, int dkSize); static boolean validatePassword(String password, String correctHash); static boolean validatePassword(byte[] password, String correctHash); static byte[] pbkdf2(byte[] password, byte[] salt, int iterations, int bytes); }
PasswordHash { public static String createHash(String password) { Args.notBlank(password, "password"); return createHash(StringUtil.toUtf8Bytes(password)); } private  PasswordHash(); static String createHash(String password); static String createHash(byte[] password); static String createHash(byte[] password, int saltSize, int iterations, int dkSize); static boolean validatePassword(String password, String correctHash); static boolean validatePassword(byte[] password, String correctHash); static byte[] pbkdf2(byte[] password, byte[] salt, int iterations, int bytes); static final int SALT_BYTE_SIZE; static final int DERIVED_KEY_SIZE; static final int PBKDF2_ITERATIONS; static final int ITERATION_INDEX; static final int SALT_INDEX; static final int PBKDF2_INDEX; }