This commit is contained in:
六如
2024-12-01 13:10:32 +08:00
parent 09330a7431
commit c0cfdbafd9
22 changed files with 1584 additions and 513 deletions

View File

@@ -0,0 +1,73 @@
# 签名算法
签名步骤如下:
1.筛选并排序
获取所有请求参数不包括字节类型参数如文件、字节流剔除sign字段剔除值为空的参数并按照参数名ASCII码递增排序字母升序排序如果遇到相同字符则按照第二个字符的键值ASCII码递增排序以此类推。
2.拼接
将排序后的参数与其对应值,组合成“参数=参数值”的格式,并且把这些参数用&字符连接起来,此时生成的字符串为待签名字符串。
3.调用签名函数
使用各自语言对应的`SHA256WithRSA`签名函数并使用应用私钥对待签名字符串进行签名对结果Base64编码。
4.把生成的签名赋值给`sign`参数,拼接到请求参数中。
- 示例
假设目前已经存在一个接口:获取会员信息
- 接口名member.info.get
- 版本号1.0
- 请求方式GET
- 请求参数name=jim&age=123&address=xxx
它的业务参数为:
```
name=jim
age=22
address=xx
```
加上公共请求参数:
```
app_id=test_2020050924567817013559296
method=member.info.get
version=1.0
charset=UTF-8
timestamp=2019-06-03 15:18:29
sign=(待生成)
```
把业务请求参数和公共请求参数加起来然后按照参数名ASCII码递增排序
则待签名字符串为:
```
address=xx&age=22&app_id=test_2020050924567817013559296&charset=UTF-8&method=member.info.get&name=jim&timestamp=2020-06-03 15:23:30&version=1.0
```
使用各自语言对应的`SHA256WithRSA`签名函数并使用`应用私钥`对待签名字符串进行签名对结果Base64编码得到字符串`adfdxadsf3asdfa`
把该字符串给`sign`参数,拼接到请求参数中,得到最终请求参数为:
```
name=jim
age=22
address=xx
app_id=test_2020050924567817013559296
method=member.info.get
version=1.0
charset=UTF-8
timestamp=2019-06-03 15:18:29
sign=adfdxadsf3asdfa
```
如果开放平台已经提供SDK那么SDK中已经封装好签名步骤直接调用SDK中的方法即可完成接口请求。

View File

@@ -0,0 +1,93 @@
---
# frontmatter: https://jekyllrb.com/docs/front-matter/
layout: post
title: Blogging Like a Hacker
---
## Markdown Basic Syntax
I just love **bold text**. Italicized text is the _cat's meow_. At the command prompt, type `nano`.
My favorite markdown editor is [ByteMD](https://github.com/bytedance/bytemd).
1. First item
2. Second item
3. Third item
a
> Dorothy followed her through many of the beautiful rooms in her castle.
```js
import gfm from '@bytemd/plugin-gfm'
import { Editor, Viewer } from 'bytemd'
const plugins = [
gfm(),
// Add more plugins here
]
const editor = new Editor({
target: document.body, // DOM to render
props: {
value: '',
plugins,
},
})
editor.on('change', (e) => {
editor.$set({ value: e.detail.value })
})
```
## GFM Extended Syntax
Automatic URL Linking: https://github.com/bytedance/bytemd
~~The world is flat.~~ We now know that the world is round.
- [x] Write the press release
- [ ] Update the website
- [ ] Contact the media
| Syntax | Description |
| --------- | ----------- |
| Header | Title |
| Paragraph | Text |
## Footnotes
Here's a simple footnote,[^1] and here's a longer one.[^bignote]
[^1]: This is the first footnote.
[^bignote]: Here's one with multiple paragraphs and code.
Indent paragraphs to include them in the footnote.
`{ my code }`
Add as many paragraphs as you like.
## Gemoji
Thumbs up: :+1:, thumbs down: :-1:.
Families: :family_man_man_boy_boy:
Long flags: :wales:, :scotland:, :england:.
## Math Equation
Inline math equation: $a+b$
$$
\displaystyle \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)
$$
## Mermaid Diagrams
```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```