@Test void testHashWithMistakesEnabled() { HashService hashService = new BCryptHashService(true, true); String plaintext = "Password"; String hashed = hashService.hash(plaintext); assertTrue(hashService.isMatch(plaintext, hashed)); String capsLock = "pASSWORD"; assertTrue(hashService.isMatch(capsLock, hashed)); String extraFirstCharacter = "*Password"; assertTrue(hashService.isMatch(extraFirstCharacter, hashed)); String extraLastCharacter = "Password-"; assertTrue(hashService.isMatch(extraLastCharacter, hashed)); String firstCharacterCaseSwap = "password"; assertTrue(hashService.isMatch(firstCharacterCaseSwap, hashed)); }
@Override public String hash(String plaintext) { if (serverSideHashEnabled()) { return BCrypt.withDefaults().hashToString(10, plaintext.toCharArray()); } return plaintext; }
BCryptHashService extends HashService { @Override public String hash(String plaintext) { if (serverSideHashEnabled()) { return BCrypt.withDefaults().hashToString(10, plaintext.toCharArray()); } return plaintext; } }
BCryptHashService extends HashService { @Override public String hash(String plaintext) { if (serverSideHashEnabled()) { return BCrypt.withDefaults().hashToString(10, plaintext.toCharArray()); } return plaintext; } BCryptHashService(boolean serverSideHashEnabled, boolean allowCommonMistakes); }
BCryptHashService extends HashService { @Override public String hash(String plaintext) { if (serverSideHashEnabled()) { return BCrypt.withDefaults().hashToString(10, plaintext.toCharArray()); } return plaintext; } BCryptHashService(boolean serverSideHashEnabled, boolean allowCommonMistakes); @Override String hash(String plaintext); }
BCryptHashService extends HashService { @Override public String hash(String plaintext) { if (serverSideHashEnabled()) { return BCrypt.withDefaults().hashToString(10, plaintext.toCharArray()); } return plaintext; } BCryptHashService(boolean serverSideHashEnabled, boolean allowCommonMistakes); @Override String hash(String plaintext);  }