多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## hutool里的hash算法 ~~~ public static void main(String[] args) { String str = "中国"; // additiveHash 加法hash int i1 = HashUtil.additiveHash(str, 2147483647); System.out.println("additiveHash:"+i1); // rotatingHash 旋转hash int i2 = HashUtil.rotatingHash(str, 2147483647); System.out.println("rotatingHash:"+i2); // oneByOneHash 一次一个hash int i3 = HashUtil.oneByOneHash(str); System.out.println("oneByOneHash:"+i3); // bernstein Bernstein's hash int i4 = HashUtil.bernstein(str); System.out.println("bernstein:"+i4); // fnvHash 改进的32位FNV算法1 int i5 = HashUtil.fnvHash(str); System.out.println("fnvHash:"+i5); // intHash Thomas Wang的算法,整数hash int i6 = HashUtil.intHash(20000); System.out.println("intHash:"+i6); // rsHash RS算法hash int i7 = HashUtil.rsHash(str); System.out.println("rsHash:"+i7); // rsHash RS算法hash int i8 = HashUtil.jsHash(str); System.out.println("jsHash:"+i8); // pjwHash PJW算法 int i9 = HashUtil.pjwHash(str); System.out.println("pjwHash:"+i9); // elfHash ELF算法 int i10 = HashUtil.elfHash(str); System.out.println("elfHash:"+i10); // bkdrHash BKDR算法 int i11 = HashUtil.bkdrHash(str); System.out.println("bkdrHash:"+i11); // sdbmHash SDBM算法 int i12 = HashUtil.sdbmHash(str); System.out.println("sdbmHash:"+i12); // djbHash DJB算法 int i13 = HashUtil.djbHash(str); System.out.println("djbHash:"+i13); // dekHash DEK算法 int i14 = HashUtil.dekHash(str); System.out.println("dekHash:"+i14); // apHash AP算法 int i15 = HashUtil.apHash(str); System.out.println("apHash:"+i15); // tianlHash TianL Hash算法 long i16 = HashUtil.tianlHash(str); System.out.println("tianlHash:"+i16); // javaDefaultHash JAVA自己带的算法 int i17 = HashUtil.javaDefaultHash(str); System.out.println("javaDefaultHash:"+i17); // mixHash 混合hash算法,输出64位的值 long i18 = HashUtil.mixHash(str); System.out.println("mixHash:"+i18); /** * universal Universal Hashing * zobrist Zobrist Hashing */ } ~~~ 输出 ``` additiveHash:42284 rotatingHash:308781 oneByOneHash:-1442747735 bernstein:682698 fnvHash:2098402689 intHash:-1926344886 rsHash:1048268992 jsHash:1688412080 pjwHash:342477 elfHash:342477 bkdrHash:2643972 sdbmHash:1312855056 djbHash:6542607 dekHash:629597 apHash:-40989346 tianlHash:33826199 javaDefaultHash:642672 mixHash:2760257320457601 ```