路加密单个int [英] Way to encrypt a single int

查看:200
本文介绍了路加密单个int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么能便宜两路加密32位int,使得每个号码映射到在该领域的一些其他的int和背部的方式,很难predict?

How can you inexpensively two-way encrypt a 32 bit int, such that every number maps to some other int in that space and back in a way that's difficult to predict?

和不需要$ P $对存储当然4.29十亿个整数中的映射表,

And doesn't require pre-storing 4.29 billion ints in a mapping table, of course.

推荐答案

你想要的是一个32位的分组密码。不幸的是,大多数密码块是64位或更多,由于短块大小的弱点。如果你能处理的加密INT是两倍大的投入,那么你可以只用河豚,TDES,或其他一些很好的审核64位的分组密码。

What you want is a 32-bit block cipher. Unfortunately, most block ciphers are 64-bits or more due to the weaknesses of a short block size. If you can handle the encrypted int being twice as large as the input, then you can just use Blowfish, TDES, or some other nicely vetted 64-bit block cipher.

如果你真的需要32位,不介意降低安全那么它很容易修剪像河豚的Feistel网络密码到任何块长度是2和低于起始密码的倍数。对于河豚,只是分割你输入号码均匀两个半块之间,和装饰的输出F函数和P值下降为1/2目标块尺寸。这可以键控算法照常毕竟完成。

If you really need 32 bits and don't mind the decreased security then its easy enough to trim a Feistel network cipher like Blowfish down to any block length that's a multiple of 2 and less than the starting cipher. For Blowfish, just split your input number evenly between the two half blocks, and trim the output of the F function and the P-values down to 1/2 your target block size. This can all be done after keying the algorithm as usual.

这篇关于路加密单个int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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