Here you can find the source of hashFNV64(byte[] bytes)
Parameter | Description |
---|---|
str | Value to be hashed |
public static long hashFNV64(byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { /**//from www .j av a 2 s .c om * FNV hashes are designed to be fast while maintaining a low collision rate. The FNV speed allows one to quickly hash lots of data while maintaining a reasonable collision rate. The high dispersion of the FNV hashes makes them well suited for hashing nearly identical strings such as URLs, hostnames, filenames, text, IP addresses, etc.<br><br> * The IETF has an informational draft on The FNV Non-Cryptographic Hash Algorithm: <code>http://tools.ietf.org/html/draft-eastlake-fnv-03</code> * @param str Value to be hashed * @return hex string representing the hash code */ public static long hashFNV64(String str) { return hashFNV64(str.getBytes()); } /** * FNV hashes are designed to be fast while maintaining a low collision rate. The FNV speed allows one to quickly hash lots of data while maintaining a reasonable collision rate. The high dispersion of the FNV hashes makes them well suited for hashing nearly identical strings such as URLs, hostnames, filenames, text, IP addresses, etc.<br><br> * The IETF has an informational draft on The FNV Non-Cryptographic Hash Algorithm: <code>http://tools.ietf.org/html/draft-eastlake-fnv-03</code> * @param str Value to be hashed * @return hex string representing the hash code */ public static long hashFNV64(byte[] bytes) { long nHashVal = 0xcbf29ce484222325L; long nMagicPrime = 0x00000100000001b3L; for (int i = 0; i < bytes.length; i++) { nHashVal ^= bytes[i]; nHashVal *= nMagicPrime; } return nHashVal; } }