NodeJS: decipher attachment - SOLVED
To answer my own question above how to fully decipher attachment and display image. The image is now able to display.
// PreDownload: Grabbing the url from previous step
const { data } = await axios.get("https://cvws.icloud-content.com/M/M...", { responseType: 'arraybuffer' });
const iv = Buffer.alloc(16); // buffer alloc fills with zeros
const key = Buffer.from(attachmentKey.slice(2), 'hex',);
const decipher = crypto.createDecipheriv("aes-256-ctr", key, iv);
decipher.setAutoPadding(false); // No Padding
let decrypted = decipher.update(data); // if input is a buffer don't choose a encoding its ignored
decrypted += decipher.final('base64'); // tried 'binary' & 'base64'
// Write decode decrypted data into a buffer than write to file
fs.writeFileSync("myImg.jpeg", Buffer.from(decrypted, 'base64'))
Post
Replies
Boosts
Views
Activity
NodeJs: Decryption of Business Chat Attachment
I've tried the NodeJS steps above but to no unveil. I'm not sure what I'm missing here. Although I'm unable to display the image. I'm confident that this is a decipher issue.
// PreDownload: Grabbing the url from previous step
const { data } = await axios.get("https://cvws.icloud-content.com/M/M...", { responseType: 'arraybuffer' });
const iv = Buffer.alloc(16); // buffer alloc fills with zeros
const key = Buffer.from(attachmentKey.slice(2), 'hex',);
const decipher = crypto.createDecipheriv("aes-256-ctr", key, iv);
decipher.setAutoPadding(false); // No Padding
let decrypted = decipher.update(data); // if input is a buffer don't choose a encoding its ignored
decrypted += decipher.final('base64'); // tried 'binary' & 'base64'
// Write decrypted data to myImg.jpeg
fs.writeFileSync("myImg.jpeg", decrypted)