I need to replicate .NET code in Node.js. My hard requirement is that Triple DES encryption needs to performed with 16 byte Key & 16 byte IV. However, I searched all over but couldn't find that combination with any Node.js package. The following code complains that IV length needs to be 8 bytes in length. And it does work if I make it 8 bytes.
const crypto = require('crypto');
const text = "4111111111111111";
const des_key = Buffer.from([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]);
const des_iv = Buffer.from([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]);
const cipher = crypto.createCipheriv("DES-EDE-CBC", des_key, des_iv);
const encryptedText = cipher.update(text,'utf8','base64') + cipher.final('base64');
console.log("EncryptedText: " + encryptedText);
I tried other algoritms but couldn't find the length combinations I need. See my findings below.
DES-ECB - Key: 8; IV: 0
DES-CBC - Key: 8; IV: 8
DES-CFB - Key: 8; IV: 8
DES-CFB1 - Key: 8; IV: 8
DES-CFB8 - Key: 8; IV: 8
DES-EDE-CBC - Key: 16; IV: 8
DES-EDE-CFB - Key: 16; IV: 8
DES-EDE-OFB - Key: 16; IV: 8
DES-EDE3-CBC - Key: 24; IV: 8
DESX-CBC - Key: 24; IV: 8
Will greatly appreciate any help that I can get.