From 090c04440c208172dfda102c9ad0138130f1c3f9 Mon Sep 17 00:00:00 2001 From: Slava Bacherikov Date: Fri, 22 Jul 2016 21:28:51 +0300 Subject: [PATCH] Update FSI 20 digits code --- scripts/decrypt_bios.ts | 19 ++++++++++++++++--- spec/bios.spec.js | 6 +++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/scripts/decrypt_bios.ts b/scripts/decrypt_bios.ts index 4e63656..661e4da 100644 --- a/scripts/decrypt_bios.ts +++ b/scripts/decrypt_bios.ts @@ -181,7 +181,7 @@ function InsydeSolver(serial: string): string[] { } /* For Fujinsu-Siemens. 5x4 dicimal digits */ -function FSI20DecOldSolver(serial: string): string[] { +function FSI20DecOldSolver(serial: string): string { let ord = (str: string) => str.charCodeAt(0); function swap (arr: T[], i1: number, i2: number): void { @@ -240,7 +240,20 @@ function FSI20DecOldSolver(serial: string): string[] { ).join(""); } - return [decryptCode_old(codeToBytes(serial))]; + return decryptCode_old(codeToBytes(serial)); +} + +/* For Fujinsu-Siemens. 5x4 dicimal digits. new */ +function FSI20DecNewSolver(serial: string): string { + const f_keys = [ + "4798156302", "7201593846", "5412367098", "6587249310", + "9137605284", "3974018625", "8052974163" + ]; + + return [0, 2, 5, 11, 13, 15, 16].map((val, i, arr) => { + let temp = parseInt(serial.charAt(val), 10); + return f_keys[i].charAt(temp); + }).join(""); } export let CleanSerial = (serial: string) => serial.trim().replace(/-/gi, ""); @@ -287,7 +300,7 @@ export let FSI20DecOld: BIOSDecoder = { name: "Fujitsu-Siemens old", examples: ["1234-4321-1234-4321-1234"], check: (s) => /^\d{20}$/i.test(s), - solve: FSI20DecOldSolver + solve: (serial) => [FSI20DecNewSolver(serial), FSI20DecOldSolver(serial)] }; export let Decoders: BIOSDecoder[] = [ diff --git a/spec/bios.spec.js b/spec/bios.spec.js index 683230e..dd99438 100644 --- a/spec/bios.spec.js +++ b/spec/bios.spec.js @@ -49,11 +49,11 @@ describe("Decryp BIOS", function() { expect(bios.Insyde.check("12345678d")).toBe(false); }); - it("FSI 20 dec old key for 1234-4321-1234-4321-1234 is 10cphf0b", function() { + it("FSI 20 dec old key for 1234-4321-1234-4321-1234 is 7122790 or 10cphf0b", function() { expect(bios.FSI20DecOld.solve(bios.CleanSerial("1234-4321-1234-4321-1234"))) - .toEqual(["10cphf0b"]); + .toEqual(["7122790", "10cphf0b"]); expect(bios.FSI20DecOld.solve(bios.CleanSerial("1234-4321-1234-4321-1236"))) - .toEqual(["100phf0b"]); + .toEqual(["7122790", "100phf0b"]); }) });