#848 Prevent "invalid salt version" when hash format is clearly not BCrypt

This commit is contained in:
ljacqu
2016-08-13 20:10:38 +02:00
parent 58308cffb5
commit 7f3c308009
5 changed files with 27 additions and 3 deletions
@@ -113,4 +113,14 @@ public class HashUtilsTest {
assertThat(digest.getAlgorithm(), equalTo("MD5"));
}
@Test
public void shouldCheckForValidBcryptHashStart() {
// given / when / then
assertThat(HashUtils.isValidBcryptHash(""), equalTo(false));
assertThat(HashUtils.isValidBcryptHash("$2afsdaf"), equalTo(true));
assertThat(HashUtils.isValidBcryptHash("$2"), equalTo(false));
assertThat(HashUtils.isValidBcryptHash("$2aead234adef"), equalTo(true));
assertThat(HashUtils.isValidBcryptHash("#2ae5fc78"), equalTo(false));
}
}