- Created .gitignore to exclude build artifacts and dependencies. - Added package.json and package-lock.json for project dependencies and scripts. - Included pnpm workspace configuration for managing packages. - Implemented TypeScript configuration in tsconfig.json. - Added README.md with project description and usage instructions. - Introduced native code for DES encryption and decryption in C/C++. - Created initial decoded data structure for handling scan results. - Established basic file structure for decoded outputs and native builds.
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
import fs from "fs";
|
|
import os from "os";
|
|
import path from "path";
|
|
|
|
export function projectRoot(): string {
|
|
const fromDir = path.resolve(__dirname, "..");
|
|
if (fs.existsSync(path.join(fromDir, "package.json"))) {
|
|
return fromDir;
|
|
}
|
|
return process.cwd();
|
|
}
|
|
|
|
export function binDir(): string {
|
|
return path.join(projectRoot(), "bin");
|
|
}
|
|
|
|
export function exeName(base: string): string {
|
|
return process.platform === "win32" ? `${base}.exe` : base;
|
|
}
|
|
|
|
export function runnerPath(kind: "cpu" | "metal" | "cuda"): string | null {
|
|
const names: Record<typeof kind, string> = {
|
|
cpu: "med_cpu",
|
|
metal: "med_gpu",
|
|
cuda: "med_cuda",
|
|
};
|
|
const p = path.join(binDir(), exeName(names[kind]));
|
|
return fs.existsSync(p) ? p : null;
|
|
}
|
|
|
|
export function metalShaderPath(): string {
|
|
return path.join(projectRoot(), "native", "metal", "des_bruteforce.metal");
|
|
}
|
|
|
|
export function defaultMedPath(): string {
|
|
const root = projectRoot();
|
|
try {
|
|
const match = fs.readdirSync(root).find((name) => name.toLowerCase().endsWith(".med"));
|
|
if (match) {
|
|
return path.join(root, match);
|
|
}
|
|
} catch {
|
|
/* ignore */
|
|
}
|
|
return "";
|
|
}
|
|
|
|
export function defaultOutDir(): string {
|
|
return path.join(projectRoot(), "decoded", "bruteforce");
|
|
}
|
|
|
|
export function cpuCoreCount(): number {
|
|
return Math.max(1, os.cpus().length);
|
|
}
|