Skip to main content

A pure Python implementation of LZRW1/KH compression algorithm

Project description

python-lzrw1-kh

This is a pure Python implementation of LZRW1/KH compression algorithm. Python 2 and Python 3 are supported. This implementation is based on the C implementation by Kurt Haenen and the Delphi implementation by Danny Heijl.

This implementation is slow and not suitable for large files.

Installation

pip3 install python-lzrw1-kh
pip3 install https://github.com/nmantani/python-lzrw1-kh/archive/refs/heads/master.zip

Usage

lzrw1_kh.compress() and lzrw1_kh.decompress() take bytes as an argument and return compressed / decompressed bytes.

>>> import lzrw1_kh
>>> lzrw1_kh.compress(b'AAAAAAAABBBBBBBBCCCCCCCC')
b'\x0c\x00@T\x00A\x00\x14B\x00\x14C\x00\x14'
>>> lzrw1_kh.decompress(b'\x0c\x00@T\x00A\x00\x14B\x00\x14C\x00\x14')
b'AAAAAAAABBBBBBBBCCCCCCCC'
>>> 
>>> import hashlib
>>> import lzrw1_kh
>>> data = b"\x90"*1024
>>> hashlib.md5(data).hexdigest()
'e03067ea0b33933f67508ff1f8d0d4d0'
>>> compressed = lzrw1_kh.compress(data)
>>> len(compressed)
9
>>> decompressed = lzrw1_kh.decompress(compressed)
>>> len(decompressed)
1024
>>> hashlib.md5(decompressed).hexdigest()
'e03067ea0b33933f67508ff1f8d0d4d0'
>>> 

Author

Nobutaka Mantani (Twitter: @nmantani)

License

The BSD 2-Clause License (http://opensource.org/licenses/bsd-license.php)

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-lzrw1-kh-0.1.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file python-lzrw1-kh-0.1.tar.gz.

File metadata

  • Download URL: python-lzrw1-kh-0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for python-lzrw1-kh-0.1.tar.gz
Algorithm Hash digest
SHA256 a64b87c69bac7eb35eb5a9da398b17cb3ecb00dcb676d5206bd55d4bd1bfa84f
MD5 3fbc1e0db7c9297bea58c584db585ed5
BLAKE2b-256 049efce30a838a7605690e2fddf3e16b94fb456d085df00c26e45a693c455e5d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page