compress/README.md
Jack Wines 43afd380c4
decompression works
I also added a cli interface
2024-04-15 19:18:24 -07:00

19 lines
941 B
Markdown

Compresses files using [Huffman coding](https://en.wikipedia.org/wiki/Huffman_coding).
On [The Great Gatsby in plain text](https://www.gutenberg.org/cache/epub/64317/pg64317.txt) on project Gutenberg, it achieves a 0.526 compression ratio when using a word size of two bytes. On an arbitrary RAW image, it peaks at .622 with a 32 bit word size and .645 with a 16 bit one.
To run with [Nix](nixos.org):
``` sh
nix run ".#" --experimental-features "nix-command flakes" -- compress < myFile > myFile.compressed
nix run ".#" --experimental-features "nix-command flakes" -- decompress < myFile.compressed > myFile-decompressed
sha256sum myFile myFile-decompressed
wc -c myFile.compressed myFile
```
To run with [cabal](https://www.haskell.org/ghcup/):
``` sh
cabal run . -- compress < myFile > myFile.compressed
cabal run . -- decompress < myFile > myFile-decompressed
sha256sum myFile myFile-decompressed
wc -c myFile.compressed myFile
```