Created
September 6, 2026 20:15
-
-
Save dapize/fb5d2c64e5eca266444310e9238b6bfb to your computer and use it in GitHub Desktop.
Photofiltre_X_generate_reg_code.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as readline from "readline"; | |
| function GenerateRegCode(name: string): string { | |
| const Data = [0x7b, 0x4d, 0x86, 0x4e, 0x63, 0x45, 0xbc]; | |
| let Result = ""; | |
| if (name.length >= 5) { | |
| let S = name.toLowerCase().replace(/ /g, ""); | |
| let T = 0; | |
| for (let i = S.length - 1; i >= 0; i--) { | |
| T += S.charCodeAt(i) - i - 1; | |
| } | |
| S = | |
| String(T % 0x3e8).padStart(3, " ") + | |
| String(S.length % 0x64).padStart(2, "0") + | |
| "01234"; | |
| for (let i = 0; i < 10; i++) { | |
| Result += (Data[(i + 1) % 7] ^ S.charCodeAt(i)) | |
| .toString(16) | |
| .toUpperCase() | |
| .padStart(2, "0"); | |
| } | |
| Result = Result.slice(0, 5) + "-" + Result.slice(5, 10) + "-" + Result.slice(10, 15) + "-" + Result.slice(15, 20); | |
| return Result; | |
| } else { | |
| return ""; | |
| } | |
| } | |
| const rl = readline.createInterface({ | |
| input: process.stdin, | |
| output: process.stdout, | |
| }); | |
| rl.question("Enter registration name: ", (name) => { | |
| if (name.trim() === "") { | |
| console.log("-> Name can't be empty!"); | |
| } else if (name.length < 5) { | |
| console.log("-> Name must have at least 5 characters!"); | |
| } else { | |
| console.log("My Key: " + GenerateRegCode(name)); | |
| } | |
| rl.close(); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment