-
Notifications
You must be signed in to change notification settings - Fork 5
/
getDS.ts
32 lines (30 loc) · 854 Bytes
/
getDS.ts
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
/**
* @description ds 算法
* @since Alpha v0.2.0
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha v0.2.0
*/
// Tauri.Genshin
import { MD5 } from "./tools";
import TGConstant from "../constant/TGConstant";
/**
* @description 获取 ds
* @since Alpha v0.2.0
* @version 2.34.1
* @param {string} query 查询字符串
* @param {string} body 请求体
* @returns {string} ds
*/
export function getDS (query: string, body: string = ""): string {
const params = {
salt: TGConstant.SALT.Other.X4,
t: Math.floor(Date.now() / 1000).toString(),
r: Math.floor(Math.random() * 100000 + 100000).toString(),
b: body,
q: query,
};
const paramStr = `salt=${params.salt}&t=${params.t}&r=${params.r}&b=${params.b}&q=${params.q}`;
const md5Str = MD5(paramStr);
const ds = `${params.t},${params.r},${md5Str}`;
return ds;
}