Skip to content

moabazid/HuffmanPHP

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

huffman-php

Usage

<?php

use Mordilion\HuffmanPHP\Dictionary;
use Mordilion\HuffmanPHP\Huffman;

$text = 'This is a Text to compress with the Huffman-Algorythem';

// Dictionary where each array element will be one dictionary entry 
$dictionary = new Dictionary([$text], Dictionary::MAX_LENGTH_WHOLE_WORDS);

// Dictionary with max 1 character length
$dictionary = new Dictionary([$text], 1);

// Dictionary with 1-2 character length
$dictionary = new Dictionary([$text], 2);

$huffman = new Huffman($dictionary);

echo $huffman->encode($text, false); // just the huffman binary code
echo $huffman->encode($text, true); // compressed with the internal base conversion - Slow but far more compressed and URL-Safe

About

A library to provide the Huffman algorithem in PHP. Includes also a compressing of the proceed Binary

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%