是否有加密技术可以将8位数字转换成10位或11位以下的数字? [英] Is there an encryption technique that could turn an 8-digit number into something 10 or 11 digits or less?

查看:702
本文介绍了是否有加密技术可以将8位数字转换成10位或11位以下的数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到的许多加密技术可以轻松加密一个简单的8位数字,如12345678,但结果通常是像8745b34097af8bc9de087e98deb8707aac8797d097f(组成,但你得到的想法)。



有没有办法加密这个8位数字,但结果加密值是相同还是至少只有稍长一些的数字?一个理想的目标是最终得到10位数或更少的数字。这是可能的,同时仍然保持相当强的加密?



更新:我没有使输出清楚 - 我想要一个8位数字变成8位数,而不是8字节。

解决方案

这里有很多取决于你对密钥加密标签。您是否真的想要公钥加密,还是只是考虑到这种可能性?



如果您愿意使用对称加密,则从8生成8个字节的输出字节的输入是非常简单的:只需运行3DES在ECB(电子代码本)模式,这就是你会得到的。 ECB的主要缺点是给定的输入将始终产生相同的结果,所以如果您的输入可能重复,攻击者将能够看到重复,并且可能会注意到加密值X导致操作Y 即使他们根本不能/不打破加密本身。如果你能生活在这里,3DES / ECB可能是你的答案。



如果你不能这样做,CFES模式下的3DES可能是最好的。这将从8个字节的输入产生16个字节的输出(注意,输入大小通常不会加倍,而是增加8个字节到输入大小)。



3DES是几乎没有人会称之为尖端算法,但我认为它仍然符合相当强大的加密。作为一种算法的一部分弱点来自于其相对较小的块大小,但也可以最小化扩展的输出。



编辑:对不起,我忘了公钥可能性。对于大多数公钥加密,最小的结果大致等于密钥大小。通过RSA加密,这通常意味着最少的像1024位(通常相当多)。为了保持结果更小,我可能会使用椭圆曲线加密术,对于已知的攻击,一个〜200位的密钥是相当安全的。这仍然会比3DES / CFB要大,但不是太过分了。


Many of the encryption techniques I've seen can easily encrypt a simple 8 digit number like "12345678" but the result is often something like "8745b34097af8bc9de087e98deb8707aac8797d097f" (made up but you get the idea).

Is there a way to encrypt this 8 digit number but have the resulting encrypted value be the same or at least only a slightly longer number? An ideal target would be to end up with a 10 digit number or less. Is this possible while still maintaining a fairly strong encryption?

Update: I didn't make the output clear enough - I am wanting an 8-digit number to turn into an 8-digit number, not 8 bytes.

解决方案

A lot here is going to depend on how seriously you mean your "public-key-encryption" tag. Do you actually want public key encryption, or are you just taking that possibility into account?

If you're willing to use symmetric encryption, producing 8 bytes of output from 8 bytes of input is pretty easy: just run 3DES in ECB (Electronic Code Book) mode, and that's what you'll get. The main weakness of ECB is that a given input will always produce the same result, so if your inputs might repeat an attacker will be able to see that repetition, and may be able to notice a pattern of "encrypted value X leads to action Y", even if they can't/don't break the encryption itself at all. If you can live with that, 3DES/ECB is probably your answer.

If you can't live with that, 3DES in CFB mode is probably the next best. This will produce 16 bytes of output from 8 bytes of input (note that it's not normally doubling the input size, but adding 8 bytes to the input size).

3DES is hardly what anybody would call a cutting edge algorithm, but I'd say it still qualifies as "fairly strong encryption". Part of its weakness as an algorithm stems from its relatively small block size, but that also minimizes expansion of the output.

Edit: Sorry, I forgot to the public-key possibility. With most public-key cryptography, the smallest result is roughly equal to the key size. With RSA encryption, that'll typically mean a minimum of something like 1024 bits (and often considerably more than that). To keep the result smaller, I'd probably use Elliptical Curve Cryptography, for which a ~200 bit key is reasonably secure against known attacks. This will still be larger than 3DES/CFB, but not outrageously so.

这篇关于是否有加密技术可以将8位数字转换成10位或11位以下的数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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