Skip to content

Commit

Permalink
Update APP.md (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
catlair authored Sep 18, 2023
1 parent 4768775 commit 5603b1a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions docs/misc/sign/APP.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,38 @@ public class AppSigner {
```

输出结果为:01479cf20504d865519ac50f33ba3a7d

### TypeScript/JavaScript

```typescript
import { createHash } from 'node:crypto'

type Params = Record<string, any>

const md5 = (str: string) => createHash('md5').update(str).digest('hex')

/**
* 为请求参数进行 APP 签名
*/
export function appSign(params: Params, appkey: string, appsec: string) {
params.appkey = appkey
const searchParams = new URLSearchParams(params)
searchParams.sort()
return md5(searchParams.toString() + appsec)
}

console.log(
appSign(
{
id: 114514,
str: '1919810',
test: 'いいよ,こいよ',
},
'1d8b6e7d45233436',
'560c52ccd288fed045859ed18bffd973',
),
'01479cf20504d865519ac50f33ba3a7d',
)
```

输出结果为:01479cf20504d865519ac50f33ba3a7d

0 comments on commit 5603b1a

Please sign in to comment.