Hawkynt

PackBits RLE

Classic run-length encoding algorithm used in TIFF images, PostScript, and early Apple computer systems. Simple but effective for data with runs of identical bytes.

Properties

Property Value
Category Compression Algorithms
Sub-category Run-Length Encoding
Security status Not classified
Complexity Not specified
Inventor Apple Computer
Year 1984
Origin πŸ‡ΊπŸ‡Έ United States
Source algorithms/compression/packbits.js

Security

Status: not classified β€” treat as unverified.

No vulnerabilities are recorded for this implementation.

Documentation

References

Test vectors

8 vectors ship with this algorithm and run in the test suite. Byte values are hexadecimal.

Vector 1 β€” Empty input

Field Value
input (empty)
expected (empty)

Vector 2 β€” Single byte literal

Field Value
input 41
expected 0041

Vector 3 β€” Simple run of 3 identical bytes

Field Value
input 414141
expected fe41

Vector 4 β€” Three different literals

Field Value
input 414243
expected 02414243

Vector 5 β€” Run followed by literals

Field Value
input 41414141424344
expected fd4102424344

Vector 6 β€” Literals followed by run

Field Value
input 41424344444444
expected 02414243fd44

Vector 7 β€” Maximum run length (128 bytes)

Field Value
input 41414141414141414141414141414141 41414141414141414141414141414141 41414141414141414141414141414141 41414141414141414141414141414141 41414141414141414141414141414141 41414141414141414141414141414141 41414141414141414141414141414141 41414141414141414141414141414141
expected 8141

Vector 8 β€” Maximum literal sequence (128 bytes)

Field Value
input 000102030405060708090a0b0c0d0e0f 101112131415161718191a1b1c1d1e1f 202122232425262728292a2b2c2d2e2f 303132333435363738393a3b3c3d3e3f 404142434445464748494a4b4c4d4e4f 505152535455565758595a5b5c5d5e5f 606162636465666768696a6b6c6d6e6f 707172737475767778797a7b7c7d7e7f
expected 7f000102030405060708090a0b0c0d0e 0f101112131415161718191a1b1c1d1e 1f202122232425262728292a2b2c2d2e 2f303132333435363738393a3b3c3d3e 3f404142434445464748494a4b4c4d4e 4f505152535455565758595a5b5c5d5e 5f606162636465666768696a6b6c6d6e 6f707172737475767778797a7b7c7d7e 7f

← All algorithms