Clean up sertial from spaces and dash symbols

This commit is contained in:
Slava Bacherikov committed 2016-07-22 20:57:20 +03:00
1 parent b6e3dee587
commit eac6dda446
2 files changed
+10 -4

No files matched your search

+5 -2
View File
@@ -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);
+5 -2
View File
@@ -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"]);
})
});