You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
966 B
31 lines
966 B
// ds_runner.js
|
|
const path = require('path');
|
|
const DeepSeekHash = require('./ds'); // 就是你那份不依赖 fs-extra 的 ds.js
|
|
|
|
async function main() {
|
|
// 读取 stdin
|
|
const input = await new Promise((resolve, reject) => {
|
|
let s = '';
|
|
process.stdin.setEncoding('utf8');
|
|
process.stdin.on('data', c => s += c);
|
|
process.stdin.on('end', () => resolve(s));
|
|
process.stdin.on('error', reject);
|
|
});
|
|
const p = JSON.parse(input || '{}');
|
|
|
|
const wasmPath = p.wasmPath || path.join(__dirname, 'sha3_wasm_bg.wasm');
|
|
|
|
const dsh = new DeepSeekHash();
|
|
await dsh.init(wasmPath);
|
|
|
|
const ans = dsh.calculateHash(
|
|
p.algorithm, p.challenge, p.salt, p.difficulty, p.expireAt
|
|
);
|
|
|
|
process.stdout.write(JSON.stringify({ ok: true, answer: ans }));
|
|
}
|
|
|
|
main().catch(err => {
|
|
process.stdout.write(JSON.stringify({ ok: false, error: String(err && err.stack || err) }));
|
|
process.exitCode = 1;
|
|
});
|