https://github.com/cronokirby/huffman-rs
An implementation of Huffman coding
https://github.com/cronokirby/huffman-rs
compression huffman-coding rust
Last synced: 3 months ago
JSON representation
An implementation of Huffman coding
- Host: GitHub
- URL: https://github.com/cronokirby/huffman-rs
- Owner: cronokirby
- License: mit
- Created: 2019-03-06T20:32:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-11T01:36:11.000Z (over 6 years ago)
- Last Synced: 2025-01-28T04:29:09.704Z (5 months ago)
- Topics: compression, huffman-coding, rust
- Language: Rust
- Size: 55.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Huffman
This is a little command line program using [Huffman Coding](https://en.wikipedia.org/wiki/Huffman_coding)
to compress and decompress files## Usage
```
USAGE:
huffmanFLAGS:
-h, --help Prints help information
-V, --version Prints version informationSUBCOMMANDS:
decode Decode a file
encode Encode a file
help Prints this message or the help of the given subcommand(s)
```
Huffman features 2 modes, encoding and decoding. The typical use case is first using the `encode`
command to compress a file, and then the `decode` file to decompress it later.## Encoding
```
USAGE:
huffman encode -oFLAGS:
-h, --help Prints help information
-V, --version Prints version informationOPTIONS:
-o The output file to put the decoded text intoARGS:
The input file to encode
```
This encodes a file by counting the occurrences of each byte in the file,
and using that to construct a Huffman tree and assign a bit pattern to each byte.
The output is a binary file, prefixed with the byte counts, and then followed
by a stream of encoded bytes. Because we include the byte counts at the start of the file,
we can rebuild the Huffman tree when decompressing the file.## Decoding
```
USAGE:
huffman decode -oFLAGS:
-h, --help Prints help information
-V, --version Prints version informationOPTIONS:
-o The output file to put the decoded text intoARGS:
The input file to decode
```
This is the reverse of the encoding operation. This must be used on a file
encoded with the same version of the program, otherwise unkown results will happen.