我已经下载并编译了openssl-1.1.0.
我可以加密,并使用相同的exe解密openssl(如这里)
me@ubuntu:~/openssl-1.1.0$ LD_LIBRARY_PATH=. ./apps/openssl aes-256-cbc -a -salt -in file.txt -out file.txt.enc
enter aes-256-cbc encryption password: 123
Verifying - enter aes-256-cbc encryption password:
me@ubuntu:~/openssl-1.1.0$ LD_LIBRARY_PATH=. apps/openssl aes-256-cbc -a -d -in file.txt.enc -out file.txt.dec
enter aes-256-cbc decryption password: 123
Run Code Online (Sandbox Code Playgroud)
这openssl用于:libcrypto.so.1.1, libssl.so.1.1
当我尝试openssl使用我的ubuntu上安装的解密时,它使用:
/lib/x86_64-linux-gnu/libssl.so.1.0.0, /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
我收到一个错误:
me@ubuntu:~/openssl-1.1.0$ openssl aes-256-cbc -a -d -in file.txt.enc -out file.txt.dec2
enter aes-256-cbc decryption password: 123
bad decrypt
140456117421728:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:evp_enc.c:539:
Run Code Online (Sandbox Code Playgroud)
可能是什么原因导致的 谢谢
我想用Node加密字符串,并用CryptoJS在浏览器中解密字符串。
加密:
var crypto = require('crypto');
function encrypt(txt, cryptkey) {
var cipher = crypto.createCipher('aes-256-cbc', cryptkey);
var crypted = cipher.update(txt, 'utf8', 'hex');
crypted += cipher.final('hex');
return crypted;
}
encrypt('1', 'key'); // 83684beb6c8cf063caf45cb7fad04a50
Run Code Online (Sandbox Code Playgroud)
包括:
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>
Run Code Online (Sandbox Code Playgroud)
解密:
var decrypted = CryptoJS.AES.decrypt('83684beb6c8cf063caf45cb7fad04a50', 'key');
console.log(decrypted.toString(CryptoJS.enc.Utf8)); // empty string
Run Code Online (Sandbox Code Playgroud)
实际结果是空字符串。
从节点解密数据的正确方法是什么?
cryptography ×2
aes ×1
cryptojs ×1
encryption ×1
javascript ×1
libssl ×1
linux ×1
node.js ×1
openssl ×1