可逆的“哈希”从64位整数到64位整数的函数 [英] Reversible "hash" function from 64-bit integer to 64-bit integer

查看:90
本文介绍了可逆的“哈希”从64位整数到64位整数的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的是一个可逆函数,该函数将 long (64位整数)转换为另一个 long 数字,方式是对于用户来说似乎是随机的(但实际上是确定性的),因此将3个后续数字转换为3个彼此完全不同的数字。

What I need is a reversible function that transforms a long (64-bit integer) into another long number, in a way that seems "random" for a user (but actually is deterministic), so that 3 subsequent numbers are transformed into 3 numbers completely different to each other.

这很容易做到

基本上,这是与可逆的哈希函数?,但是我需要超过2 ^ 32个不同的值。

Basically it's the same question as Reversible hash function?, but I need more than 2^32 distinct values.

任何想法?

PS:我要用Java编写它,但是问题本身是很普通的。

PS: I'm going to write it in Java, but the question itself is pretty generic.

推荐答案

这些是分组密码的基本要求,通常使用Feistel结构来实现: https:// en.wikipedia.org/wiki/Feistel_cipher

These are the basic requirements for a block cipher, which is usually implemented with a Feistel structure: https://en.wikipedia.org/wiki/Feistel_cipher


  1. 创建低32位的哈希并将其与高32位进行异或位

  2. 交换上下32位

  3. 重复几次。

这篇关于可逆的“哈希”从64位整数到64位整数的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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