Add HPmini code

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

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[] {

View file

@ -23,4 +23,15 @@ describe("Decryp BIOS", function() {
expect(bios.Samsung.check("0123456")).toBe(false);
expect(bios.Samsung.check("07088a20410C00")).toBe(true);
});
it("HPMini key for CNU1234ABC is e9l37fvcpe", function() {
expect(bios.HPMini.solve("CNU1234ABC")).toEqual(["e9l37fvcpe"]);
});
it("HPMini input validation", function() {
expect(bios.HPMini.check("CNU1234ABC")).toBe(true);
expect(bios.HPMini.check("CNU1234ABCV")).toBe(false);
expect(bios.HPMini.check("CNU12$4ABC")).toBe(false);
expect(bios.HPMini.check("CNU12п4ABC")).toBe(false);
});
});