具有雪崩效果的java字符串哈希函数 [英] java string hash function with avalanche effect

查看:369
本文介绍了具有雪崩效果的java字符串哈希函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用String.hashCode()进行测试时,我注意到它没有雪崩效果。我知道有一个詹金斯散列的Java端口,但我想知道是否有一个哈希函数,也许在一些Apache库或其他东西,有这个属性。

In testing with String.hashCode() I noticed that it does not have an avalanche effect. I know that there's a java port of Jenkins hash, but I was wondering if there's a hash function, maybe in some apache library or something, that has this property.

编辑:我正在寻找一个函数,展现此属性,并返回一个32位(或64位)整数(例如,像Jenkins散列)。我没有将它用于密码学,并且我不打算一般替换String.hashCode。我只是认为hashCode有这个属性,事实证明它不是,我想知道是否有任何Java的标准库或可能是一个Apache的lib,满足我的需要。

I'm looking for a function that exhibits this property, and returns a 32-bit (or 64-bit) integer (for example, like Jenkins hash). I'm not using it for cryptography, and I'm not intending to replace String.hashCode in general. I just thought hashCode had this property, and it turns out it doesn't, and I'm wondering if there's anything in java's standard libs or maybe an apache lib, that satisfies my need.

推荐答案

对于加密哈希函数,请查看 JCA ,它允许生成SHA-1,MD5和其他加密摘要,这些摘要都具有您正在寻找的效果。

For cryptographic hash functions, look at JCA, which allows generating SHA-1, MD5, and other cryptographic digests, which all have the effect you're looking for.

这篇关于具有雪崩效果的java字符串哈希函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆