dsxml2169 2019-08-23 07:33 采纳率: 0%
浏览 818

不同语言版本的Murmurhash会得到不同的结果

I've tried three version of murmurhash in java(jedis and guava), go and python. The result of java(guava),go and python version output same hash code but different with java(jedis). All the murmurhash code are shown as follow. I'm confused about the result. I've seen this issue and use Long.reverseBytes in java, and still different with others. So what should I do to make all the output of murmurhash keep same. Thanks~

1. java version(jedis)

java gradle compile group: 'redis.clients', name: 'jedis', version: '3.1.0'

import redis.clients.jedis.util.MurmurHash;

MurmurHash murmurhash = new MurmurHash();
long h = murmurhash.hash("foo");
System.out.println(h);
System.out.println(Long.reverseBytes(h));

output:

-7063922479176959649

6897758107479832477

2. golang version

import "github.com/spaolacci/murmur3"

foo := int64(murmur3.Sum64WithSeed([]byte("foo"), 0x1234ABCD))
fmt.Println(foo)

output:

-5851200325189400636

3. python version

pip install mmh3

import mmh3

foo = mmh3.hash64('foo', seed=0x1234ABCD, signed=True)
print(foo)

output:

-5851200325189400636

4. java(guava)

java gradle compile group: 'com.google.guava', name: 'guava', version: '28.0-jre'

import com.google.common.hash.Hashing

long foo = Hashing.murmur3_128(0x1234ABCD).hashString("foo", charset.forName("UTF-8")).asLong();
System.out.println(foo);

output:

-5851200325189400636
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 CreateBitmapFromWicBitmap内存释放问题。
    • ¥30 win c++ socket
    • ¥15 CanMv K210开发板实现功能
    • ¥15 C# datagridview 栏位进度
    • ¥15 vue3页面el-table页面数据过多
    • ¥100 vue3中融入gRPC-web
    • ¥15 kali环境运行volatility分析android内存文件,缺profile
    • ¥15 写uniapp时遇到的问题
    • ¥15 vs 2008 安装遇到问题
    • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率