Appendix B. Previous IETF FNV Code
Dieser Abschnitt bewahrt den RFC-Text zu FNV, einschliesslich FNV primes, offset_basis, endianism, XOR folding, constants, non-cryptographic security guidance, source code, test code, Makefile und Vergleichen mit SHA-1 and SHA-256.
Originaler RFC-Text
Appendix B. Previous IETF FNV Code
FNV-1a was referenced in draft-ietf-tls-cached-info-08 (which was
ultimately published as RFC 7924, but RFC 7924 no longer contains the
code below). Herein, we provide the Java code for FNV64 from that
earlier draft, included with the kind permission of the author:
<CODE BEGINS>
/*
* Java code sample, implementing 64 bit FNV-1a
* By Stefan Santesson
*/
import java.math.BigInteger;
public class FNV {
static public BigInteger getFNV1a64Digest (String inpString) {
BigInteger m = new BigInteger("2").pow(64);
BigInteger fnvPrime = new BigInteger("1099511628211");
BigInteger fnvOffsetBasis = new BigInteger
("14695981039346656037");
BigInteger digest = fnvOffsetBasis;
for (int i = 0; i < inpString.length(); i++) {
digest = digest.xor(BigInteger.valueOf(
(int) inpString.charAt(i)));
digest = digest.multiply(fnvPrime).mod(m);
}
return (digest);
}
}
<CODE ENDS>