@Test void testHashWithMistakesEnabled() { HashService hashService = new Sha256HashService(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 plaintext; } var salt = generateSalt(SALT_LENGTH); var hashed = HashUtilities.performHash("SHA-256", salt + plaintext).toLowerCase(); LOG.info("Generated salt {} of length {} when performing SHA-256 hash.", salt, salt.length()); return salt + hashed; }
Sha256HashService extends HashService { @Override public String hash(String plaintext) { if (!serverSideHashEnabled()) { return plaintext; } var salt = generateSalt(SALT_LENGTH); var hashed = HashUtilities.performHash("SHA-256", salt + plaintext).toLowerCase(); LOG.info("Generated salt {} of length {} when performing SHA-256 hash.", salt, salt.length()); return salt + hashed; } }
Sha256HashService extends HashService { @Override public String hash(String plaintext) { if (!serverSideHashEnabled()) { return plaintext; } var salt = generateSalt(SALT_LENGTH); var hashed = HashUtilities.performHash("SHA-256", salt + plaintext).toLowerCase(); LOG.info("Generated salt {} of length {} when performing SHA-256 hash.", salt, salt.length()); return salt + hashed; } Sha256HashService(boolean serverSideHashEnabled, boolean allowCommonMistakes); }
Sha256HashService extends HashService { @Override public String hash(String plaintext) { if (!serverSideHashEnabled()) { return plaintext; } var salt = generateSalt(SALT_LENGTH); var hashed = HashUtilities.performHash("SHA-256", salt + plaintext).toLowerCase(); LOG.info("Generated salt {} of length {} when performing SHA-256 hash.", salt, salt.length()); return salt + hashed; } Sha256HashService(boolean serverSideHashEnabled, boolean allowCommonMistakes); @Override String hash(String plaintext); }
Sha256HashService extends HashService { @Override public String hash(String plaintext) { if (!serverSideHashEnabled()) { return plaintext; } var salt = generateSalt(SALT_LENGTH); var hashed = HashUtilities.performHash("SHA-256", salt + plaintext).toLowerCase(); LOG.info("Generated salt {} of length {} when performing SHA-256 hash.", salt, salt.length()); return salt + hashed; } Sha256HashService(boolean serverSideHashEnabled, boolean allowCommonMistakes); @Override String hash(String plaintext);  }