Length Values โ€‹โ€‹from Deflation Algorithm

I compressed the text "TestingTesting" and the result of hex was: 0B 49 2D 2E C9 CC 4B 0F 81 50 00. I can not determine the length and distance codes. The binary snapshot is reverse because the RFC says to read a bit from right to left (thanks to Matthew Slatter for help). Here is what has been analyzed so far:

1 BFINAL (last block) 01 BTYPE (static) 1000 0100 132-48= 84 T 1001 0101 149-48= 101 e 1010 0011 163-48= 115 s 1010 0100 164-48= 116 t 1001 1001 153-48= 105 i 1001 1110 158-48= 110 n 1001 0111 151-48= 103 g 

These are the remaining bits that I cannot parse:

 1000 0100 0000 1000 0101 0000 0000 0 

The final 10 bits (the end of the block value is x100) is the only part I can analyze. I think that the values โ€‹โ€‹of length and distance should be 7 (binary 0111), since the length of the "Testing" is 7 letters, and after the current position it copies 7 characters, but I canโ€™t figure out how to represent it in the remaining bits. What am I doing wrong?

+4
source share
1 answer

The distance code is 5, but the distance code 5 is followed by one โ€œextra bitโ€ to indicate the actual distance is 7 or 8. (See the second table in paragraph 3.2.5 of the RFC.)

Full data decoding:

 1 BFINAL 01 BTYPE=static 10000100 'T' 10010101 'e' 10100011 's' 10100100 't' 10011001 'i' 10011110 'n' 10010111 'g' 10000100 another 'T' 0000100 literal/length code 260 = length 6 00101 distance code 5 0 extra bit => the distance is 7 0000000 literal/length code 256 = end of block 
+4
source

All Articles