Qraft

Encode and Decode

Encoding transforms data into a different format according to defined rules; decoding reverses the transformation to recover the original data. This paired operation underpins all digital technology - character encoding (UTF-8), image compression (JPEG), and encryption (AES) all follow this pattern.

QR code generation is encoding: input data passes through mode selection, bit conversion, error correction addition, mask application, and module placement to produce a black-and-white symbol. Scanning is decoding: image recognition, module extraction, mask removal, error correction, and bit-to-data restoration execute in reverse order within milliseconds.

Four encoding modes optimize for different data types: Numeric (~3.3 bits/character), Alphanumeric (~5.5 bits), Kanji (13 bits), and Byte (8 bits). Mode selection directly affects code size, making encoder optimization critical for compact codes.

Reed-Solomon error correction ensures robust decoding. Extra data added during encoding allows recovery of the original bit stream even when modules are damaged or obscured - trading encoding overhead for decoding reliability.