@Test void testHashDifferent() { String plaintext = "password"; String secondPlaintext = "secondPassword"; String result = hashService.hash(plaintext); String secondResult = hashService.hash(secondPlaintext); assertTrue(hashService.isMatch(plaintext, result)); assertTrue(hashService.isMatch(secondPlaintext, secondResult)); assertFalse(hashService.isMatch(plaintext, secondResult)); assertFalse(hashService.isMatch(secondPlaintext, result)); }
@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);  }