diff --git a/scripts/decrypt_bios.ts b/scripts/decrypt_bios.ts index 772da53..4e63656 100644 --- a/scripts/decrypt_bios.ts +++ b/scripts/decrypt_bios.ts @@ -243,6 +243,8 @@ function FSI20DecOldSolver(serial: string): string[] { return [decryptCode_old(codeToBytes(serial))]; } +export let CleanSerial = (serial: string) => serial.trim().replace(/-/gi, ""); + export let Sony: BIOSDecoder = { model: BIOSModels.Sony, name: "Sony", @@ -284,7 +286,7 @@ export let FSI20DecOld: BIOSDecoder = { model: BIOSModels.FSIPhoenix, name: "Fujitsu-Siemens old", examples: ["1234-4321-1234-4321-1234"], - check: (s) => true, + check: (s) => /^\d{20}$/i.test(s), solve: FSI20DecOldSolver }; @@ -301,4 +303,5 @@ export function runDecoders(serial: string, decoders: BIOSDecoder[]): FindResult [runDecoder(serial, dec), dec]).filter(res => res[0].length > 0); } -export let findPassword = (serial: string) => runDecoders(serial, Decoders); +export let findPassword = (serial: string) => + runDecoders(CleanSerial(serial), Decoders); diff --git a/spec/bios.spec.js b/spec/bios.spec.js index d79008a..683230e 100644 --- a/spec/bios.spec.js +++ b/spec/bios.spec.js @@ -50,7 +50,10 @@ describe("Decryp BIOS", function() { }); it("FSI 20 dec old key for 1234-4321-1234-4321-1234 is 10cphf0b", function() { - expect(bios.FSI20DecOld.solve("12344321123443211234")).toEqual(["10cphf0b"]); - expect(bios.FSI20DecOld.solve("12344321123443211236")).toEqual(["100phf0b"]); + expect(bios.FSI20DecOld.solve(bios.CleanSerial("1234-4321-1234-4321-1234"))) + .toEqual(["10cphf0b"]); + + expect(bios.FSI20DecOld.solve(bios.CleanSerial("1234-4321-1234-4321-1236"))) + .toEqual(["100phf0b"]); }) });