2

I'm trying to decrypt zip file using crypto provided file is in s3 storage and I have password for the file and no info for IV. I'm using cryptoDecipher but getting error cryptoDecipher is deprecated. I saw some post saying use createDecipheriv but I don't have any IV that I can use.

below is a sample code -

function demo(entry){
    password = 'mypassword';
    algorithm = 'aes-256-cbc';
    let decrypt = crypto.createDecipher(algorithm,password)
    let res = entry.stream().pipe(decrypt);
    const uploadParams = {
        Body:res,
        Bucket:myS3bucket,
        key:myfilename,
    }
    uploadfile(uploadParams)
}

I'm using unzipper to unzip file and getting 'entry as object for file so just using that object in demo function'

help me out as I'm new to streams and crypto lib.

Arpit jain
  • 89
  • 6
  • The ZIP file format has it's own encryption system where each entry is encrypted individually. As you only have a password it is very likely that the ZIP file is just encrypted using that encryption and not as a binary file as you are trying to decrypt it. Open and extract the ZIP file using a program like 7-Zip and the provided password and you will see if it works. – Robert Dec 28 '22 at 14:04
  • Hi robert, I have a use case to do this with nodejs only not with any application. Appreciate your comment. – Arpit jain Dec 29 '22 at 04:13
  • Before writing a program in any language you should make sure that you have understood the data format you want to read. Instead of just trying different decryption variants which don't work you should really start by manually examine the ZIP you have e.g. using 7-zip. – Robert Dec 29 '22 at 08:10
  • Hi Robert I have info regarding zip file- Method - AES-256 Deflate, Characteristics -WzAES Encrypt Descriptor UTF-8, HostOs- Unix, Name- myfile.csv,Type- zip – Arpit jain Dec 29 '22 at 08:56
  • Have you tried https://stackoverflow.com/questions/48817111/unzip-a-password-protected-archive-using-node-js or https://www.chilkatsoft.com/refdoc/nodejsZipRef.html or https://www.npmjs.com/package/archiver-zip-encrypted?activeTab=readme – Robert Dec 29 '22 at 08:58
  • I need to deal with decryption, in the link zip encrypted and 1st link not deal with decryption and chilkatsoft is what I cannot use in project. – Arpit jain Jan 02 '23 at 07:23
  • I tried chilkat solution it is working but I need a stream of unzipped file so that I can upload it back to S3 but I cannot find any way to get stream of unzipped files using chilkat – Arpit jain Jan 03 '23 at 09:18

0 Answers0