-
- /**
- * Implements the FNV-1 64bit algorithm.
- * FNV-1 128bit would be ideal for 16 bytes but we need an overhead for Base64 encoding.
- * Otherwise, the hash cannot be stored in a UTF-8 string.
- * https://www.wikiwand.com/en/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#/FNV-1_hash
- * https://github.com/pmdamora/fnv-cracker-app/blob/master/src/main/java/passwordcrack/cracking/HashChecker.java
- * @param stringdata the String to be hashed
- * @return the hash string
- */
- private String fnv(String stringdata) {
- BigInteger hash = FNV_INIT;
- byte[] data = stringdata.getBytes(StandardCharsets.UTF_8);
-
- for (byte b : data) {
- hash = hash.multiply(FNV_PRIME).mod(FNV_MOD);
- hash = hash.xor(BigInteger.valueOf((int) b & 0xff));
- }
-
- return Base64.getEncoder().encodeToString(hash.toByteArray());
- }