UNPKG

qrmanual

Version:

Implementação de QR Code v2-L (25×25, correção L) em TypeScript

28 lines (27 loc) 807 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LOG_TABLE = exports.EXP_TABLE = void 0; exports.gfMul = gfMul; // 1) Cria as duas tabelas como instâncias de Uint8Array exports.EXP_TABLE = new Uint8Array(512); exports.LOG_TABLE = new Uint8Array(256); (function initGF() { let x = 1; for (let i = 0; i < 255; i++) { exports.EXP_TABLE[i] = x; exports.LOG_TABLE[x] = i; x <<= 1; if (x & 0x100) x ^= 0x11d; } for (let i = 255; i < 512; i++) { exports.EXP_TABLE[i] = exports.EXP_TABLE[i - 255]; } })(); // 3) Multiplicação em GF(256) function gfMul(a, b) { if (a === 0 || b === 0) return 0; const idx = exports.LOG_TABLE[a] + exports.LOG_TABLE[b]; return exports.EXP_TABLE[idx]; }