存档:TS 重构前基线(lx 聚合源 = isolated-vm 加载器,签名方案已移除)
This commit is contained in:
commit
f289df4cd7
124 files changed
+14110
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import crypto from 'node:crypto'
|
||||
|
||||
const PART_1_INDEXES = [23, 14, 6, 36, 16, 40, 7, 19]
|
||||
const PART_2_INDEXES = [16, 1, 32, 12, 19, 27, 8, 5]
|
||||
const SCRAMBLE_VALUES = [89, 39, 179, 150, 218, 82, 58, 252, 177, 52, 186, 123, 120, 64, 242, 133, 143, 161, 121, 179]
|
||||
|
||||
async function hashSHA1(data) {
|
||||
return crypto.createHash('sha1').update(data).digest('hex')
|
||||
}
|
||||
|
||||
function pickHashByIdx(hash, indexes) {
|
||||
return indexes.map((idx) => hash[idx]).join('')
|
||||
}
|
||||
|
||||
function base64Encode(data) {
|
||||
return Buffer.from(data)
|
||||
.toString('base64')
|
||||
.replace(/[\\/+=]/g, '')
|
||||
}
|
||||
|
||||
export async function zzcSign(text) {
|
||||
const hash = await hashSHA1(text)
|
||||
const part1 = pickHashByIdx(hash, PART_1_INDEXES)
|
||||
const part2 = pickHashByIdx(hash, PART_2_INDEXES)
|
||||
const part3 = SCRAMBLE_VALUES.map((value, i) => value ^ parseInt(hash.slice(i * 2, i * 2 + 2), 16))
|
||||
const b64Part = base64Encode(part3).replace(/[\\/+=]/g, '')
|
||||
return `zzc${part1}${b64Part}${part2}`.toLowerCase()
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
import { httpFetch } from '../../request.js'
|
||||
import { zzcSign } from './crypto.js'
|
||||
|
||||
export const signRequest = async(data) => {
|
||||
// console.log(data)
|
||||
const sign = await zzcSign(JSON.stringify(data))
|
||||
// console.log('sign', sign)
|
||||
return httpFetch(`https://u.y.qq.com/cgi-bin/musics.fcg?sign=${sign}`, {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'User-Agent': 'QQMusic 14090508(android 12)',
|
||||
},
|
||||
body: data,
|
||||
}).promise
|
||||
}
|
||||
Reference in new issue
Block a user