简体   繁体   中英

Compress base64 string in python and extract it in PHP

I'm sending a base64 string compressed with zlib in Python, converted to base64, sent to a PHP page where it will be extracted.

I'm having trouble with this. How would I do this?

Right now I have:

python

compressor = zlib.compressobj(wbits=(16+zlib.MAX_WBITS))
compressed = compressor.compress(str)
compressed += compressor.flush()

php

*POST deccoded here, b64data is the output*
$b64data = zlib_decode($data);

I left out the part where I decode from base64. The php code throws and error about invalid data at the zlib function. zlib_decode(): data error

Ok, I messed up and the problem wasn't with the zlib function.

Long story short I used to encode the data twice on the Python side but changed it to only encode once and never removed the extra base64_decode from the PHP.

Thanks for the help guys.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM