<分区>
我有以下用于加密的 c++ 代码片段:
EVP_CIPHER_CTX ctx;
const EVP_CIPHER * cipher = EVP_des_ede3_cbc();
unsigned char iv[EVP_MAX_IV_LENGTH];
unsigned char key[EVP_MAX_KEY_LENGTH];
String seed;
_config->get_value("crypto_seed", &seed); // uses the seed value from pimp config.
if (seed.is_empty())
{
return false;
}
EVP_BytesToKey(cipher, EVP_sha1(),
(unsigned char *) 0, // no salt
reinterpret_cast<unsigned char *>(const_cast<char *>(seed.chars())), seed.length(),
1, // hash passphrase just once.
key, iv);
EVP_CIPHER_CTX_init(&ctx);
EVP_CipherInit_ex(&ctx, cipher, (ENGINE *) 0, key,
iv,
1); // encrypt
Java 中的 c++ 加密等价于什么?
我看到有des
算法,然后我看到sha1
。
这个和openssl加密有关。但不确定什么是等效的。本质上,我想要与 C++ 代码生成的输出相同。
我在问什么是 EVP_CIPHER_CTX
的等价物,或者这里使用的加密名称是什么,所以我可以从那里获取它。
编辑:不要求任何人将代码转换为 java,只要求相应的包或类做同样的事情。