seller api /reports/2020-09-04/documents/amzn1.tortuga.3.18666cbf-dfdf-dsfsd-bf4b-sdfdsfsdfsdf.TBWRJF481G44N
response
{ "payload": { "reportDocumentId": "amzn1.tortuga.3.18666cbf-dfdf-dsfsd-bf4b-sdfdsfsdfsdf.TBWRJF481G44N", "encryptionDetails": { "standard": "AES", "initializationVector": "nG2rSrj1Ra9e03IStEBkdg==", "key": "9CT0qwtzUHLXlFTh0aLxk4qSQYAJ7texG8KDIZ0JSy8=" }, "url": "https://tortuga-prod-eu.s3-eu-west-1.amazonaws.com/%2FNinetyDays/amzn1.tortuga.3.18666cbf-e671-asds-sdfs-dsfdsfdsfds.sdvfdsdssdfsd?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20201208T192515Z&X-Amz-SignedHeaders=host&X-Amz-Expires=300&X-Amz-Credential=dscfdsfsdfsdfdsfsdf%2F20201208%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Signature=45hjkkjkjdfdsfsd4545jkkjhkj4554j" } }
decryption nodejs code
const crypto = require('crypto');
const algorithm = 'AES';
const key = '9CT0qwtzUHLXlFTh0aLxk4qSQYAJ7texG8KDIZ0JSy8='; const iv = 'nG2rSrj1Ra9e03IStEBkdg==';
const decipher = crypto.createDecipheriv(algorithm, key, iv);
Error - Invalid IV length
No idea about node js but I have implemented this API in PHP and it works for me. This might be helpful for you.
$key = base64_decode('xxxxx');
$iv = base64_decode('xxxxxx');
$decryptedData = openssl_decrypt(file_get_contents($url), 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
Works perfect! Thanks!
The key & Iv has to be base64 decoded