Hi guys I am wondering if anyone has experience using nodejs to decrypt fields from Salesforce using the encryptWithManagedIV guide here
I have tried implementing something from this post
http://salesforce.stackexchange.com/questions/70518/how-to-decrypt-aes-256-in-node-js
But keep getting the invalid IV length:
for example this is what i did:
var crypto = require('crypto'),
algorithm = 'aes-256-cbc',
password = '<generated_private_key>';
function decrypt(text) {
var buf = Buffer.from(text, 'base64');
var iv = buf.toString('binary', 0, 16);
console.log(iv.length);
var crypt = buf.toString('base64', 16);
var decipher = crypto.createDecipheriv(algorithm, password, iv);
decipher.setAutoPadding(false);
var dec = decipher.update(crypt, 'base64', 'utf-8');
dec += decipher.final('utf-8');
return dec;
}
console.log(decrypt("<encrypted_value_from_salesforce>"));
via lodoss118
No comments:
Post a Comment