1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| const crypto = require('crypto');
const method = "POST"; const endpoint = "/i/api/1.1/jot/error_log.json"; const yr_o = [ 39, 54, 185, 185, 21, 119, 54, 200, 58, 152, 93, 231, 27, 248, 40, 145, 226, 205, 178, 9, 181, 30, 91, 248, 37, 27, 71, 55, 89, 15, 9, 197, 42, 182, 81, 240, 111, 220, 135, 157, 167, 129, 114, 128, 131, 230, 75, 46 ]; const yr_u = [112, 196, 183, 3]; const sc = ["-", "0"]; const salt = "my_secret_key";
const Wr = 1682924400; const u = Math.floor((Date.now() - Wr * 1000) / 1000); const c = new Uint8Array(new Uint32Array([u]).buffer);
const content = "some_verification_token"; const e = new Uint8Array([...atob(btoa(content))].map(c => c.charCodeAt(0)));
const i = "170a3d70a3d70a0170a3d70a3d70a100";
const additionalData = `${u}obfiowerehiring${e.slice(0, 8).map(b => b.toString(16).padStart(2, '0')).join('')}${i}`; console.log("additionalData:", additionalData);
## 1. 哈希前拼接 const input = [method, endpoint, additionalData].join("!") + salt; console.log("哈希前拼接:", input);
## 2. SHA256 哈希 const hash = crypto.createHash('sha256').update(input).digest(); console.log("SHA256 哈希 (hex):", hash.toString('hex'));
## 3. 哈希后拼接 const concatArray = [ ...yr_o, ...yr_u, ...hash, 3, ...sc.map(c => c.charCodeAt(0)) ];
const concatString = String.fromCharCode(...concatArray);
console.log("哈希后拼接 (字符串):", JSON.stringify(concatString)); console.log("拼接字符串长度:", concatString.length);
## 4. Base64 编码 const xClientTransactionId = Buffer.from(concatString).toString('base64').replace(/=/g, ''); console.log("x-client-transaction-id:", xClientTransactionId);
|