Dictionary-based compression using sliding window technique. Encodes data as a flat, self-describing stream of literal/match tokens (1 flag byte, then either a raw byte or a little-endian distance+length pair) found via a hash-chain match finder over a sliding history buffer. Foundation for many modern compression formats like DEFLATE.
| Property | Value |
|---|---|
| Category | Compression Algorithms |
| Sub-category | Dictionary |
| Security status | Not classified |
| Complexity | Intermediate |
| Inventor | Abraham Lempel, Jacob Ziv |
| Year | 1977 |
| Origin | 🇮🇱 Israel |
| Source | algorithms/compression/lz77.js |
Status: not classified — treat as unverified.
No vulnerabilities are recorded for this implementation.
5 vectors ship with this algorithm and run in the test suite. Byte values are hexadecimal.
Vector 1 — Empty input - zero-byte output, no header/container
| Field | Value |
|---|---|
input |
(empty) |
expected |
(empty) |
Vector 2 — Single byte - encoded as one literal token
| Field | Value |
|---|---|
input |
41 |
expected |
0041 |
Vector 3 — No repeated patterns - worst case
| Field | Value |
|---|---|
input |
41424344 |
expected |
0041004200430044 |
Vector 4 — Repetition compression - AAAA
| Field | Value |
|---|---|
input |
41414141 |
expected |
00410101000300 |
Vector 5 — Pattern repetition - ABCABC
| Field | Value |
|---|---|
input |
414243414243 |
expected |
0041004200430103000300 |