java加密与nodejs解密
发布于 11 年前 作者 hf201429 13422 次预览 最后一次回复是 9 年前 来自 问答
我们公司用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中对应应该用哪个进行解密啊?求各路大神指导下。
6 回复
http://nodejs.org/api/crypto.html
你可以看看这个,虽然我也不清楚 DESede 对应哪个
根据: 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
去 crypto 里面找到对应算法就好了
引用自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
** 常识:DES的密匙长度是 56Bits 3DES的密匙长度是 168Bits **
谢谢各位
楼主 我有一个类似问题,困扰我很久了,您能帮我分析下吗? Java里面key是直接数组 KEY: private static byte[] getDesKey() { byte[] key = new byte[24]; MessageDigest digest; String norInfo = “asfasdadsf asdfasi12”; try { digest = MessageDigest.getInstance(“md5”); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e.getMessage(), e); }
}
var bytes = [], char; str = encodeURI(str);
while (str.length) { char = str.slice(0, 1); str = str.slice(1);
}
return bytes; };
nodejs加密和java加密出来始终不对。能指导下吗?