Ask questionscrypto, bad decrypt

I have decrypt some string which was encrypt by 3des ecb,but fail. for example:

var crypto = require('crypto');
var theCipher = "ccZmMULq3tlzAY+iafZz+96xz+qFsAuGpEjhN7CckJTcdBT03fgobfSVGCGYzILyPNSA3e3msUqHUTCpv8kRnWvFdLv9c+GTEhg+Lj5dOThGDHtkQX2j5bd6Eubw9/l+Lcwj0PeyW0ZoVkB5Nnp1yCnmKAn2Euliq+IurgthT+wln6cQmTjXfL4IB5VxwUEb72FcbeiCfbKxa+MxxbcQTCpli3ErSptwdp9on2k87JTPFqyyMmMRFA9VgOXpHNe43IwFzME01DyHZ+Rp/eQguTmY9FtkFIZeD2e2nrbbDbW6tlk/KOtdhGVIlIGMPNS5m8LYqlrGZlJU3JythEy+J0z1wW1owjVe9Yto2OtUe8WeKI744enBKAX4FnD4My7+/XRjbF5kf6loT9lqeMCdXFb3LDej3GVcKWbJuZjXmD4="
var key = "abcdefghijklmnopqrstuvwx"
var decrypt = crypto.createDecipheriv('des-ede3', key, "");
var s = decrypt.update(theCipher, 'base64', 'utf8');
console.log(s +'utf8'));

the orgin str is a utf8 string. then it doesn't work:

Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt at Error (native) at (crypto.js:202:26) at Object.<anonymous> (/usr/node/a.js:13:11) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) at startup (node.js:129:16) at node.js:814:3

is there anything wrong? any body can help?

and I try something like this:


Answer questions QAnders

We have had issues with the same kind of issue but between Windows and MAC when encrypting/decrypting. Adding the decrypt.setAutoPadding(false); as suggested above adds four EOT characters (hex: 0A) to the end of the decrypted file. Logging out the data to encrypt no EOT characters are present so they are added in the encrypt or the decrypt stages. I have no clue where they come from and it only happens if you encrypt on Windows and decrypt on MAC or v.v.


Related questions

--max-http-header-size= is not allowed in NODE_OPTIONS
Crash with "req.handle.writev is not a function" on Socket.Writable.uncork hot 2
pkg-exports: "." errors without a specified `main` hot 2
shutdown ENOTCONN on TLS.Socket._final hot 2
HTTP/2 requests eventually start throwing NGHTTP2_ENHANCE_YOUR_CALM errors hot 2
Assertion `(parser->current_buffer_len_) == (0)' failed hot 1
Node.js 12.10 throwing EPROTO on HTTPS request hot 1
Remove util.inherits usage internally? hot 1
[Bug] Node 10.1.0 TLS issue with ldap: Client network socket disconnected before secure TLS connection was established hot 1
ReferenceError: internalBinding is not defined hot 1
Incorrect timezone hot 1
HPE_INVALID_HEADER_TOKEN on http requests hot 1
HPE_INVALID_HEADER_TOKEN on http requests hot 1
stream.finished behaviour change hot 1
display node.js version (process.version) at the end of stacktraces hot 1
Github User Rank List