David' Scott's CONDITIONAL UNADULTERATED HUFFMAN COMPRESSIONS

files updated on December 29,1999

My main concern is to create compression routines that are of great use to the person who some day may want to compress data before encryption is used. I feel very strongly that a compression routine should be "one to one" on the previous page I give the rules for h2com.exe; However this was for 256 symbol adaptive huffman compression. This is an attempt to make the one to one feature extend to set of symbols of less than 256. you can hopefully compress one to one with as little as 2 symbol types.
Here is h2comaf.exe this routine can be used to change bases in a "one to one" way. That means if you had a file written in HEX you compress the characters to a FOF file in a unique way. Then uncompress the file in base 10. It would be a "one to one" mapping that is not a normal base conversion.
To get full use of these routines you may need the sofware to convert to and from FOF files. Here is fin2in.zip


 The files for ah2af.zip
all the programs are run like the following line

*.exe  inputfile outputfile conditionfile
ALL the comprsserors are bijective to and
from the FOF file domain. The condition file
is used to limit the domain of the binary
file to a certain set of characters. 
In other words the characters that count
must be in the condtion file.


the inputfile will either be binary or FOF
but opposite type from outfile

the ouputfile will either be binary or FOF
but opposite type from inputfile

conditionfile this file limits the 8 bit character
types in the binary file that are used in the compression
or are made from the compression.

by FOF file I mean the last byte in the file must have
at lest 1 bit set. There can be no trailing zeros bytes.
To changes to normal files where any 8 bits allowed
use fin2int.exe and to get back int2fin in the fin2in.zip
file.

h2comaf.exe  
 This is the conditional adaptive huffman compress to FOF
 format
h2comsf.exe
 This is the  conditional static huffman compress to FOF
 format the static table is made from condition file.
h2uncaf.exe  opposite of h2comaf.exe
h2uncsf.exe  opposite of h2comsf.exe

Example  compressing a file and then converting it base 7
using symbols "0123456"


let X.TXT be as follows
0000  44 45 41 52 20 4A 4F 48 4E 0D 0A 48 4F 57 20 41  *DEAR JOHN..HOW A*
0010  52 45 20 59 4F 55 20 54 4F 44 41 59 2E 20 41 4C  *RE YOU TODAY. AL*
0020  4C 20 49 53 20 46 49 4E 45 20 48 45 52 45 20 0D  *L IS FINE HERE .*
0030  0A 4F 4E 20 54 48 45 20 48 4F 4D 45 20 46 52 4F  *.ON THE HOME FRO*
0040  4E 54 2E 20 54 48 49 53 20 43 4F 4E 44 49 54 49  *NT. THIS CONDITI*
0050  4F 4E 20 0D 0A 43 4F 4D 50 52 45 53 53 20 53 55  *ON ..COMPRESS SU*
0060  52 45 20 49 53 20 4E 45 41 54 2E 20 4B 4E 4F 57  *RE IS NEAT. KNOW*
0070  20 49 20 43 41 4E 20 0D 0A 43 48 41 4E 47 45 20  * I CAN ..CHANGE *
0080  53 50 45 43 49 41 4C 20 4D 45 53 53 41 47 45 53  *SPECIAL MESSAGES*
0090  20 54 4F 20 46 4F 46 20 46 49 4C 45 53 20 0D 0A  * TO FOF FILES ..*
00A0  41 4E 44 20 54 48 45 4E 20 45 4E 43 52 59 50 54  *AND THEN ENCRYPT*
00B0  20 54 48 45 4D 20 57 49 54 48 20 53 43 4F 54 54  * THEM WITH SCOTT*
00C0  31 36 46 2E 5A 49 50 20 0D 0A 57 48 49 43 48 20  *16F.ZIP ..WHICH *
00D0  57 49 4C 4C 20 48 41 4E 44 4C 45 20 46 4F 46 20  *WILL HANDLE FOF *
00E0  46 49 4C 45 53 2E 20 4F 52 20 49 20 43 41 4E 20  *FILES. OR I CAN *
00F0  20 0D 0A 55 53 45 20 46 49 4E 32 49 44 45 41 2E  * ..USE FIN2IDEA.*
0100  45 58 45 20 54 4F 20 43 48 41 4E 47 45 20 49 54  *EXE TO CHANGE IT*
0110  20 49 4E 20 41 20 4F 4E 45 20 0D 0A 54 4F 20 4F  * IN A ONE ..TO O*
0120  4E 45 20 57 41 59 20 53 4F 20 49 44 45 41 20 43  *NE WAY SO IDEA C*
0130  41 4E 20 45 4E 43 52 59 50 54 20 49 54 2E 20 0D  *AN ENCRYPT IT. .*
0140  0A 0D 0A  .  .  .  .  .  .  .  .  .  .  .  .  .  *...*
 number of bytes is 323 

let the condition file C.TXT be as follows
0000  41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50  *ABCDEFGHIJKLMNOP*
0010  51 52 53 54 55 56 57 58 59 5A 20 30 31 32 33 34  *QRSTUVWXYZ 01234*
0020  35 36 37 38 39 2E 0D 0A  .  .  .  .  .  .  .  .  *56789...*
 number of bytes is 40 

this is output Z.TXT of "h2comaf.exe X.TXT Z.TXT C.TXT"
0000  40 22 11 C4 92 26 34 82 64 24 88 F8 31 21 47 42  *@"...&4.d$..1!GB*
0010  A8 B9 41 54 1C 74 B7 F0 5D 90 0C 10 88 94 18 30  *..AT.t..]......0*
0020  69 61 49 11 54 E5 C5 DC 48 1A F0 84 75 D0 10 0B  *iaI.T...H...u...*
0030  59 28 06 17 54 5E F5 30 C8 3A 04 25 E8 F1 C5 21  *Y(..T^.0.:.%...!*
0040  34 4C 61 51 0D 22 52 3A 8A 43 05 10 A9 6E 33 21  *4LaQ."R:.C...n3!*
0050  57 1A 24 2E 05 F1 60 97 7D 5C E1 EE 42 26 21 40  *W.$...`.}\..B&!@*
0060  D6 C1 EE 6B 7B 70 0E 83 B9 E8 D0 C3 5E 9A 07 44  *...k{p......^..D*
0070  E7 57 A5 D2 92 D1 12 15 52 8B 01 6B 03 9C D1 B6  *.W......R..k....*
0080  8D 28 DA 20 1A D6 47 02 70 AC 29 96 8D A2 55 A6  *.(. ..G.p.)...U.*
0090  48 F6 49 C6 10 D8 90 3C C1 0B EC 7F 42 80 62 69  *H.I....<....B.bi*
00A0  C8 F3 59 08 95 A2 AC 74 BA 73 5A 53 97 4E 58 A0  *..Y....t.sZS.NX.*
00B0  87 54 B8 3E 8A 65 4F 54 D7 1C 6C BD 82 6F 6A D0  *.T.>.eOT..l..oj.*
 number of bytes is 192 

let the condition file C1.TXT be the following 
0000  30 31 32 33 34 35 36  .  .  .  .  .  .  .  .  .  *0123456*
 number of bytes is 7 


THIS CODE COULD BE USED TO CAHNGE BASES AS ONE
COMPRESSES FROM ONE SYMBOL SET AND DECOMPRESSES
TO ANOTHER. THIS IS NOT MEANT FOR ENCRYPTION THOUGH
IN THEROY ANY COMPRESSION COULD BE A WEAK FORM OF
ENCRYPTION. TO USE THIS FOR ENCRYPTION TAKE THE
FOF FILE OUT AND CONVERT TO A NORMAL FILE BY THE
USE OF FIN2INT.EXE THEN ENCRYPT AND USE INT2FIN.EXE
THEN UNCOMPRESS TO THE SYMBOL SET OF CHOICE.

this is output Z1.TXT of "h2uncsf.exe Z.TXT Z1.TXT C1.TXT"
0000  33 31 31 33 34 31 33 34 32 31 30 30 30 30 33 35  *3113413421000035*
0010  31 32 33 33 31 33 35 34 31 33 33 33 34 31 32 32  *1233135413334122*
0020  30 31 32 31 30 30 34 33 34 32 33 31 36 33 30 33  *0121004342316303*
0030  32 30 36 31 34 33 36 31 34 32 31 32 36 34 35 35  *2061436142126455*
0040  32 32 30 31 36 32 35 34 31 31 34 30 31 30 34 31  *2201625411401041*
0050  30 33 33 30 31 32 31 34 30 31 32 33 33 32 31 33  *0330121401233213*
0060  30 30 30 33 34 33 36 34 32 34 35 30 33 32 36 32  *0003436424503262*
0070  31 30 30 31 35 33 32 32 31 33 31 30 35 36 35 36  *1001532213105656*
0080  31 31 33 31 31 33 32 33 32 34 34 33 31 31 35 31  *1131132324431151*
0090  33 32 36 33 30 33 32 32 35 32 33 30 32 31 35 34  *3263032252302154*
00A0  31 34 32 33 31 34 31 33 33 32 32 33 34 32 30 35  *1423141332234205*
00B0  30 33 30 30 34 34 36 31 30 32 31 32 31 33 36 31  *0300446102121361*
00C0  30 34 36 34 31 30 36 34 31 32 36 33 34 33 33 31  *0464106412634331*
00D0  32 31 34 33 34 31 33 36 34 35 35 30 35 34 30 30  *2143413645505400*
00E0  34 33 36 32 31 32 33 34 34 31 33 32 30 31 33 32  *4362123441320132*
00F0  32 30 33 32 31 34 34 35 36 32 32 33 36 32 34 32  *2032144562236242*
0100  31 35 32 35 30 30 34 31 30 32 31 30 34 33 31 34  *1525004102104314*
0110  36 35 35 31 34 32 36 32 34 36 35 35 32 35 35 30  *6551426246552550*
0120  31 31 32 36 31 34 32 35 30 32 32 33 34 36 31 35  *1126142502234615*
0130  31 35 33 32 32 33 35 33 31 34 32 33 34 34 32 34  *1532235314234424*
0140  32 33 36 32 36 34 35 36 34 33 33 33 32 33 34 31  *2362645643332341*
0150  30 30 34 33 36 33 33 30 33 32 31 31 33 32 33 32  *0043633032113232*
0160  31 31 32 30 32 30 32 33 34 36 36 36 31 32 33 33  *1120202346661233*
0170  30 35 35 33 34 31 31 34 36 35 33 32 34 31 32 30  *0553411465324120*
0180  31 33 35 30 34 33 32 31 33 30 32 34 35 33 34 36  *1350432130245346*
0190  36 31 30 36 33 32 33 35 34 34 31 32 32 35 34 34  *6106323544122544*
01A0  34 32 31 32 31 33 31 32 35 31 30 30 31 35 32 34  *4212131251001524*
01B0  30 31 30 34 35 32 36 30 35 32 32 36 31 33 30 31  *0104526052261301*
01C0  31 32 31 30 32 33 35 30 30 35 32 34 36 35 34 31  *1210235005246541*
01D0  33 34 34 33 32 33 34 33 36 30 35 36 34 35 36 34  *3443234360564564*
01E0  32 34 36 35 33 33 30 32 30 36 32 33 35 30 36 30  *2465330206235060*
01F0  33 30 31 30 34 32 33 36 34 35 30 31 32 32 36 31  *3010423645012261*
0200  36 34 30 36 33 35 32 33 36 34 36 35 30 35 30 35  *6406352364650505*
0210  35 34 35 32 35 31 34 34 36 32 36 36 33 32 35  .  *545251446266325*
 number of bytes is 543 


ENTER here for MY Home Page