DESEDE和TripleDES之间的差异for cipher.getInstance() [英] Difference between DESede and TripleDES for cipher.getInstance()

查看:750
本文介绍了DESEDE和TripleDES之间的差异for cipher.getInstance()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Java中的TripleDES加密。从键控选项下的维基百科文章,我想使用选项1,其中所有三个键都是独立的



密码文档它说要去参考指南此处,但仍不清楚我。



我正在尝试运行示例,并在不同的项目中使用这两行:

  Cipher c = Cipher.getInstance(DESede); 

密码密码= Cipher.getInstance(TripleDES / ECB / PKCS5Padding);

两个编译都好,那有什么区别?我应该用另外一个吗?这两个工作是否使用三个独立的键?

解决方案

TripleDES只是Sun中DESede的别名JCE提供程序 - 都返回完全相同的密码。 DESEDE是应用于每个Java平台的标准名称,但在实践中,TripleDES也可能被广泛支持。



根据此页面,SunJCE Triple DES实施支持选项#1和#2: p>


密码必须等于112或168。



112的密钥大小将生成具有2个中间密钥的三重DES密钥和168的密钥将生成一个具有3个中间密钥的三重DES密钥。


在实例化密码时,始终指定操作模式和填充,使您的意图清除。否则,实施可以自由选择,这可能令人困惑。


I am trying to get TripleDES encryption working in Java. From the Wikipedia article under Keying Options, I want to use option 1, where All three keys are independent.

From the Cipher docs it says to go to the reference guide here, but it still isn't clear to me.

I am working on getting examples running, and use both of these lines in different projects:

Cipher c = Cipher.getInstance("DESede");

Cipher cipher = Cipher.getInstance("TripleDES/ECB/PKCS5Padding");

Both compile fine, so what's the difference? Should I be using one over the other? Do both of these work for using three separate keys?

解决方案

"TripleDES" is simply an alias for "DESede" in the Sun JCE provider – both return the exact same cipher. "DESede" is the standard name which should work on every Java platform, but in practice, "TripleDES" is probably pretty widely supported too.

According to this page, the SunJCE Triple DES implementation supports options #1 and #2:

Keysize must be equal to 112 or 168.

A keysize of 112 will generate a Triple DES key with 2 intermediate keys, and a keysize of 168 will generate a Triple DES key with 3 intermediate keys.

You should always specify the mode of operation and the padding when instantiating a cipher to make your intents clear. Otherwise the implementation is free to make the choice, which can be confusing.

这篇关于DESEDE和TripleDES之间的差异for cipher.getInstance()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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