64Bit & 32Bit HashCode
2024-08-27 18:10:04
以下为64位和32位的hash值计算方法
public class HashUtil {
private static final long FNV_64_INIT = 0xcbf29ce484222325L;
private static final long FNV_64_PRIME = 0x100000001b3L;
private static final long FNV_32_INIT = 2166136261L;
private static final long FNV_32_PRIME = 16777619;
public static Long getUnsignedHash64(final String seed) {
Long res = 0L;
res = FNV_64_INIT;
int len = seed.length();
for (int i = 0; i < len; i++) {
res *= FNV_64_PRIME;
res ^= seed.charAt(i);
}
if (res < 0) res = -res;
return res;
}
public static Long getUnsignedHash32(final String seed) {
Long res = 0L;
res = FNV_32_INIT;
int len = seed.length();
for (int i = 0; i < len; i++) {
res *= FNV_32_PRIME;
res ^= seed.charAt(i);
}
if (res < 0) res = -res;
return res;
}
}
最新文章
- JavaWeb——Listener
- TextView使用大全
- iOS 10 都有什么改变?
- .NET 获取客户端的操作系统版本、浏览器版本和IP地址
- CentOS 6.5 zabbix 3.0.4 乱码问题
- python3爬虫再探之EXCEL
- Google浏览器的缓存文件过大(mega网站导致的)
- App.config自定义节点读取
- murri
- CVPR论文《100+ Times Faster Weighted Median Filter (WMF)》的实现和解析(附源代码)。
- bzoj3437 小P的牧场(斜率优化dp)
- Halcon示例:bottlet.hdev 光学字符识别(创建OCR)
- sql2012包含数据库,快速生成用户tsql脚本
- 对象关系_many2many
- cocos2d-x学习记录5——CCTransition场景过渡
- 【UVA1401】Remember the Word Trie+dp
- mysql数据优化--数据库结构的优化
- [Javascript] Coding interview problem: Scheduler functional way
- 第二篇-bmob云端服务器的发现
- js判断移动设备