返回提交历史
Modified
docs/misc/sign/APP.md
+35
-0
XFEstudio/bilibili-API-collect
Update APP.md (#819)
5603b1a
代码差异
1 个文件
+35
-0
@@ -131,3 +131,38 @@ public class AppSigner {
131
131
```
132
132
133
133
输出结果为:01479cf20504d865519ac50f33ba3a7d
134
135
### TypeScript/JavaScript
136
137
```typescript
138
import { createHash } from 'node:crypto'
139
140
type Params = Record<string, any>
141
142
const md5 = (str: string) => createHash('md5').update(str).digest('hex')
143
144
/**
145
* 为请求参数进行 APP 签名
146
*/
147
export function appSign(params: Params, appkey: string, appsec: string) {
148
params.appkey = appkey
149
const searchParams = new URLSearchParams(params)
150
searchParams.sort()
151
return md5(searchParams.toString() + appsec)
152
}
153
154
console.log(
155
appSign(
156
{
157
id: 114514,
158
str: '1919810',
159
test: 'いいよ,こいよ',
160
},
161
'1d8b6e7d45233436',
162
'560c52ccd288fed045859ed18bffd973',
163
),
164
'01479cf20504d865519ac50f33ba3a7d',
165
)
166
```
167
168
输出结果为:01479cf20504d865519ac50f33ba3a7d