Add HPmini code

This commit is contained in:
Slava Bacherikov committed 2016-07-22 17:24:23 +03:00
1 parent c9e4ff84d9
commit 089d7cf1b0
2 files changed
+53 -1

No files matched your search

+42 -1
View File
@@ -127,6 +127,39 @@ function SamsungSolver(serial: string): string[] {
filter(code => code ? true : false);
}
/* For HP/Compaq Netbooks. 10 chars */
function HPMiniSolver(serial: string): string[] {
const table1: {[key: string]: string} = {
"1": "3", "0": "1", "3": "F", "2": "7", "5": "Q", "4": "V",
"7": "X", "6": "G", "9": "O", "8": "U", "a": "C", "c": "E",
"b": "P", "e": "M", "d": "T", "g": "H", "f": "8", "i": "Y",
"h": "Z", "k": "S", "j": "W", "m": "4", "l": "K", "o": "J",
"n": "9", "q": "5", "p": "2", "s": "N", "r": "B", "u": "L",
"t": "A", "w": "D", "v": "6", "y": "I", "x": "4", "z": "0"
};
const table2: {[key: string]: string} = {
"1": "3", "0": "1", "3": "F", "2": "7", "5": "Q", "4": "V",
"7": "X", "6": "G", "9": "O", "8": "U", "a": "C", "c": "E",
"b": "P", "e": "M", "d": "T", "g": "H", "f": "8", "i": "Y",
"h": "Z", "k": "S", "j": "W", "m": "4", "l": "K", "o": "J",
"n": "9", "q": "5", "p": "2", "s": "N", "r": "B", "u": "L",
"t": "A", "w": "D", "v": "6", "y": "I", "x": "R", "z": "0"
};
let password1 = "";
let password2 = "";
serial = serial.toLowerCase();
for (let i = 0; i < serial.length; i++) {
password1 += table1[serial.charAt(i)];
password2 += table2[serial.charAt(i)];
}
if (password1 === password2) {
return [password1.toLowerCase()];
} else {
return [password1.toLowerCase(), password2.toLowerCase()];
}
}
export let Sony: BIOSDecoder = {
model: BIOSModels.Sony,
@@ -149,8 +182,16 @@ export let Samsung: BIOSDecoder = {
solve: SamsungSolver
};
export let HPMini: BIOSDecoder = {
model: BIOSModels.HPMini,
name: "HPMini",
examples: ["CNU1234ABC"],
check: (s) => /^[0-9A-Z]{10}$/i.test(s),
solve: HPMiniSolver
};
export let Decoders: BIOSDecoder[] = [
Sony, Samsung
Sony, Samsung, HPMini
];
export function runDecoder(serial: string, decoder: BIOSDecoder): string[] {