What is hzip
it is a cli software for zipping files with HuffmanTree Coding. the huffman_coding.py
is a demo of the tree building and text encoding
# Zip a file
hzip files
# Extract a file
hzip -x files.hzip
py huffman_coding.py
Encode Dict: {'x': '00000', 'f': '00001', 'm': '00010', 'j': '00011', 'b': '00100', 'k': '00101', 'n': '00110', 'w': '00111', 'z': '01000', 'a': '01001', 'g': '01010', 'y': '01011', 'v': '01100', 'p': '01101', 'l': '01110', 't': '01111', 'e': '100', 'q': '101000', 'T': '101001', 'c': '101010', 'i': '101011', 'o': '1011', 'u': '11000', 'h': '11001', 'd': '11010', 'r': '11011', ' ': '111'}
Text: The quick brown fox jumped over the lazy dog
text-bin: 0b10101000110100001100101001000000111000101110101011010010110001101101011001000000110001001110010011011110111011101101110001000000110011001101111011110000010000001101010011101010110110101110000011001010110010000100000011011110111011001101010111001000100000011101000110100001100101001000000110110001100001011110100111100100100000011001000110111101100111
text-len: 353
Encode:
text-bin: 0b1010011100110011110100011000101011101010001011110010011011101100111001101110000110110000011100011110000001001101100110101111011011001001101111101111110011001110111001001010000101111111010101101010
text-len: 196
Decode:
call decoder(): The quick brown fox jumped over the lazy dog