哈希UUID不需要排序 [英] Hash UUIDs without requiring ordering
本文介绍了哈希UUID不需要排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个UUID。我想完美地对它们进行哈希以产生一个唯一的值,但是有一个约束条件,即f(m,n)和f(n,m)必须生成相同的哈希。
- UUID是128位值。
- 散列函数应该没有冲突 - 所有可能的输入配对必须生成唯一的散列值
- f(m,n)和 f(n,m)必须生成相同的散列 - 也就是说,排序并不重要
- 我在Go中工作,所以结果值必须适合256位int
- 哈希不需要可逆
任何人都可以帮忙吗?
解决方案
首先将它们与较小的连接在一起。
I have two UUIDs. I want to hash them perfectly to produce a single unique value, but with a constraint that f(m,n) and f(n,m) must generate the same hash.
- UUIDs are 128-bit values
- the hash function should have no collisions - all possible input pairings must generate unique hash values
- f(m,n) and f(n,m) must generate the same hash - that is, ordering is not important
- I'm working in Go, so the resulting value must fit in a 256-bit int
- the hash does not need to be reversible
Can anyone help?
解决方案
Concatenate them with the smaller one first.
这篇关于哈希UUID不需要排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文