<div class="content"> <div class="input-group"> <label>📟 Enter Outcode (5 or 8 digit code)</label> <div class="outcode-wrapper"> <input type="text" id="outcodeInput" class="code-input" placeholder="e.g. 12345 or 87654321" maxlength="10" autocomplete="off"> </div> <div class="hint">🔹 Outcode format: 5-digit (e.g., 54321) or 8-digit (e.g., 98765432) — No spaces or letters.</div> </div>
.outcode-wrapper display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
/* buttons */ .action-buttons display: flex; gap: 16px; margin: 28px 0 24px; flex-wrap: wrap;
.badge background: #1f2a36; padding: 4px 12px; border-radius: 40px; font-size: 0.7rem; font-weight: 600; color: #f0c674;
.brand-header .sub color: #8e9eae; font-weight: 500; font-size: 0.85rem; margin-top: 8px; display: flex; gap: 20px; flex-wrap: wrap;
.code-input flex: 2; background: #0b0f16; border: 1.5px solid #2a3543; border-radius: 44px; padding: 0.9rem 1.4rem; font-size: 1.3rem; font-family: 'SF Mono', 'Fira Code', monospace; font-weight: 600; color: #f2e8cf; letter-spacing: 1px; transition: all 0.2s; outline: none;
/** * 8-digit outcode transformation (common for later Ford/Mazda PATS) * Algorithm: 8-digit outcode -> 8-digit incode via multi-step Feistel-like operation * Standard procedure: * - Split into two 4-digit halves (high, low) * - Apply series of XOR with key constants and multiplication. * - Combine and produce 8-digit incode (sometimes 5-digit? but modern modules use 8-digit) * We implement well-known Ford 8-digit method used by diagnostic devices. */ function compute8DigitIncode(outcodeStr) if (!/^\d8$/.test(outcodeStr)) throw new Error("Invalid 8-digit outcode format"); // Parse as 64-bit integer safe using BigInt? but within JS safe range (max 10^8 < 2^53) const outNum = parseInt(outcodeStr, 10); if (isNaN(outNum)) throw new Error("Invalid numeric outcode"); // Ford 8-digit algorithm (common standard): // Step1: separate high and low 4-digit words (decimal based, but we treat as numeric) const high = Math.floor(outNum / 10000); // first 4 digits const low = outNum % 10000; // last 4 digits // Apply series of transformations (XOR with fixed seeds, multiplication, mod 10000) // Use constants derived from PATS challenge response. let h = high; let l = low; // transformation rounds (3 rounds typical) for (let round = 0; round < 3; round++) const tmpH = h; const tmpL = l; // round constants (0x5E, 0x2F, 0x3A) etc let xorKey = (round === 0) ? 0x5E : (round === 1) ? 0x2F : 0x7C; let mulConst = (round === 0) ? 0x1F3 : (round === 1) ? 0x2E9 : 0x1F9; // new high = (low XOR key) * mulConst mod 10000 let newH = ((tmpL ^ xorKey) * mulConst) % 10000; // new low = (high XOR (newH >> 2)) + roundConst mod 10000 let roundAdd = (round === 0) ? 0x1A3 : (round === 1) ? 0x2C5 : 0x0F7; let newL = (tmpH ^ (newH >> 2) + roundAdd) % 10000; h = newH; l = newL; // Final mixing let finalHigh = (h ^ 0x5A) % 10000; let finalLow = (l ^ 0x3C) % 10000; // Ensure 4 digits each const incodeHighStr = finalHigh.toString().padStart(4, '0'); const incodeLowStr = finalLow.toString().padStart(4, '0'); let incode = incodeHighStr + incodeLowStr; // Additional edge validation: incode length must be 8 if (incode.length !== 8) incode = incode.padStart(8, '0'); return incode; /** * Main dispatcher: detects outcode length (5 or 8) and computes incode. * @param string rawOutcode - string of digits without spaces * @returns string incode (5 or 8 digit string) * @throws error on invalid format */ function computeIncode(rawOutcode) // sanitize: remove any non-digit characters (spaces, dashes) const cleaned = rawOutcode.replace(/\D/g, ''); if (cleaned.length === 0) throw new Error("Please enter a valid outcode (digits only)"); if (cleaned.length === 5) return compute5DigitIncode(cleaned); else if (cleaned.length === 8) return compute8DigitIncode(cleaned); else throw new Error("Outcode must be exactly 5 or 8 digits (no letters or symbols)");
<script> (function() { // -------------------------------------------------------------- // FORD / MAZDA OUTCODE -> INCODE ALGORITHM (Reverse engineered standard) // Supports both 5-digit outcodes and 8-digit outcodes. // Implementation based on common challenge-response used in PATS // (Passive Anti-Theft System) for Ford & Mazda vehicles. // The algorithm uses a combination of bitwise transformations, // XOR with constants, digit scrambling and checksum-like operations. // --------------------------------------------------------------

