我们公司用nodejs做了个项目,现在要嵌入到java做的大系统中去。其中需要涉及到java的加密和nodejs的解密。 java加密过程中:
//加密的方式
final String Algorithm = "DESede";
byte[] encoded = null;
Cipher cipher = null;
SecretKey secretKey = null;
try {
secretKey = getSecretKey(enkey,Algorithm);
cipher = Cipher.getInstance(Algorithm);
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
encoded = cipher.doFinal(reqStr);
} catch (Exception e) {
}
上述中 DESede 在nodejs中对应应该用哪个进行解密啊?求各路大神指导下。
根据: Java文档:http://docs.oracle.com/javase/7/docs/api/javax/crypto/KeyGenerator.html OpenSSL文档:http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT
DESede => 3DES
Every implementation of the Java platform is required to support the following standard KeyGenerator algorithms with the keysizes in parentheses:
- AES (128)
- DES (56)
- DESede (168)
- HmacSHA1
- HmacSHA256
引用自Java文档:http://docs.oracle.com/javase/7/docs/api/javax/crypto/KeyGenerator.html
3DES cipher suites using triple DES. DES cipher suites using DES (not triple DES).
OpenSSL文档:http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT
** 常识:DES的密匙长度是 56Bits 3DES的密匙长度是 168Bits **