mtgsig
- 内容介绍
- 文章标签
- 相关推荐
#!/usr/bin/env node
'use strict';
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
/**
* 完整的单文件mtgsig纯算离线签名器
* 支持离线生成mtgsig签名,使用预设的profile参数
*/
// ============= 基础MD5和XOR工具 =============
function md5Hex(input) {
return crypto.createHash('md5').update(input).digest('hex');
}
function xorHex(buffer, xorKeyHex) {
const xorKey = Buffer.from(xorKeyHex, 'hex');
const out = Buffer.alloc(16);
for (let i = 0; i < 16; i++) {
out[i] = buffer[i] ^ xorKey[i];
}
return out.toString('hex');
}
function getSaltFromA6(a6) {
const s = String(a6 || '');
if (!s.startsWith('h1.9') || s.length < 10) {
throw new Error('Invalid a6 payload: expected prefix h1.9 and at least 6 salt chars');
}
return s.slice(4, 10);
}
// ============= A3生成(从WEBDFPID) =============
function deriveA3FromWebdfpid(webdfpid) {
const s = String(webdfpid || '').trim();
#!/usr/bin/env node
'use strict';
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
/**
* 完整的单文件mtgsig纯算离线签名器
* 支持离线生成mtgsig签名,使用预设的profile参数
*/
// ============= 基础MD5和XOR工具 =============
function md5Hex(input) {
return crypto.createHash('md5').update(input).digest('hex');
}
function xorHex(buffer, xorKeyHex) {
const xorKey = Buffer.from(xorKeyHex, 'hex');
const out = Buffer.alloc(16);
for (let i = 0; i < 16; i++) {
out[i] = buffer[i] ^ xorKey[i];
}
return out.toString('hex');
}
function getSaltFromA6(a6) {
const s = String(a6 || '');
if (!s.startsWith('h1.9') || s.length < 10) {
throw new Error('Invalid a6 payload: expected prefix h1.9 and at least 6 salt chars');
}
return s.slice(4, 10);
}
// ============= A3生成(从WEBDFPID) =============
function deriveA3FromWebdfpid(webdfpid) {
const s = String(webdfpid || '').trim();

