将三个值包装成长的值
我有以下生成哈希的位操作:
(z shl 28) or (y shl 14) or x // (z << 28 | y << 14 | x) in java
我希望能够从上面计算的哈希中推导x,y和z。我每次都可以得到Z和X,但是我很难获得y-它只能偶尔起作用。
z始终小于4。,x和y将不超过最大短值。
这就是我在做的事情:
val hash = 684297131L // sample hash
val z = hash shr 28
val y = hash shr 14 // this works only sometimes
val x = hash and 0xfff
我认为我在这里缺少一些简单的东西,任何帮助都对此表示赞赏。
I have the following bitwise operation that generates a hash:
(z shl 28) or (y shl 14) or x // (z << 28 | y << 14 | x) in java
I want to be able to deduce x, y and z from the hash calculated above. I can get Z and X every time, but I'm having trouble getting Y - it only works occasionally.
Z will always be less than 4. And x and y will be no bigger than the max short value.
This is what I'm doing:
val hash = 684297131L // sample hash
val z = hash shr 28
val y = hash shr 14 // this works only sometimes
val x = hash and 0xfff
I think I'm missing something simple here, any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的“哈希”看起来不太像哈希。它看起来更像是将3个字段打包成长时间。
您可以获取
X
,y
和z
,产生相同的“哈希”:这可能正是您想要的。有不同的数字可以产生相同的哈希,但最简单。
Your "hash" doesn't look too much like a hash. It looks more like packing 3 fields into a long.
You can get
x
,y
, andz
that produce the same "hash" like this:This may be exactly what you want. There are different numbers that could produce the same hash, but these are the simplest.