Hawkynt

Levenshtein Coding

Universal prefix code for non-negative integers. Recursively encodes the bit-length of the bit-length (an iterated-logarithm chain) terminated by zero, so arbitrarily large integers can be represented with a self-delimiting code.

Properties

Property Value
Category Compression Algorithms
Sub-category Universal Codes
Security status Not classified
Complexity Intermediate
Inventor Vladimir I. Levenshtein
Year 1968
Origin πŸ‡·πŸ‡Ί Russia
Source algorithms/compression/levenshtein-coding.js

Security

Status: not classified β€” treat as unverified.

No vulnerabilities are recorded for this implementation.

Documentation

References

Test vectors

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

Vector 1 β€” Empty input

Field Value
input (empty)
expected 00000000

Vector 2 β€” Single small value - byte 1 (encodes value 2, code β€˜1100’)

Field Value
input 01
expected 01000000c0

Vector 3 β€” Canonical worked examples - byte values 0,1,2,3,7,8

Field Value
input 000102030708
expected 06000000b378747480

Vector 4 β€” Text sample - β€˜AB3’

Field Value
input 414233
expected 03000000f20bc83f1a00

← All algorithms