I have a string that I have compressed in javascript using lz-string.
compress.js
var compressed = LZString.compress('abc');
I can decompress it in javascript using
console.log(LZString.decompress(compressed));
I have copied the compressed string to the clipboard and I am attempting to decompress in python using lzip
decompress.py
import lzip
# compressed is the contents of the clipboard from the javascript
compressed = 'ↂテ䀀'
compressed_bytes = str.encode(compressed)
print(compressed_bytes)
print(lzip.decompress
I get the error
RuntimeError: Lzip error: Header error
Is this the right approach?
It appears that the compression implementation is different in lz-string from lzip
When I run
import lzip
compressed = 'ↂテ䀀'
python_compressed = lzip.compress_to_buffer(str.encode('abc'))
print(f'{python_compressed=}')
compressed_bytes = str.encode(compressed)
print(f'{compressed_bytes=}')
I get
python_compressed=b"LZIP\x01\x17\x000\x98\x88\xa4J\x8e\x9f\xff\xf6c\x80\x00\xc2A$5\x03\x00\x00\x00\x00\x00\x00\x00'\x00\x00\x00\x00\x00\x00\x00"
and
compressed_bytes=b'\xe2\x86\x82\xe3\x83\x86\xe4\x80\x80'
So there is a mismatch somewhere