# 签名

## 1、签名

### 1.1、签名规则

签名使用SHA1WithRSA算法. secretKey作为 SHA1WithRSA 的密钥，param中对应的参数 + timestamp 作为SHA1WithRSA的操作对象，得到的输出即为签名。

* 第一步，获取body里的请求参数，参数按字母排序之后，组成字符串
  * “参数按字母排序”的排序方式为，按照字母从小到大排序，从第一个字母开始比较，一样则比较第二个字母，再一样则比较第三个字母，依此类推。
  * 双引号全部去除，无论是字段名，还是字段值的双引号；
  * 中间不能有空格；
  * 如果字段为null,不参与签名
* 第二步，获取请求头的timestamp的参数，拼接在第一步的结果后面
* 第三步，使用secretKey 通过SHA1WithRSA 对第二步结果进行签名

### 1.2、签名示例

| 参数        | 值                                                                                   |
| --------- | ----------------------------------------------------------------------------------- |
| companyId | 220                                                                                 |
| apiKey    | 1710e1f6b4b54c15bea72e8669966591                                                    |
| secretKey | MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAI5WJjsBgtiuQQZDs5qe8LBDUm2ZSa4gTBJ |

请求参数如下：

{“companyId”:1,”lang”:”zh-CN”,”customerNo”:”86001308”}

计算签名：

* 第一步，获取body里的请求参数，参数按字母排序之后，组成下面的字符串:\
  {“companyId”:1,”customerNo”:”86001308”,”lang”:”zh-CN”}
* 第二步，获取请求头的timestamp的参数，拼接在第一步的结果后面，如下:\
  {companyId:1,customerNo:86001308,lang:zh-CN}1650361143685
* 第三步，使用secretKey 通过SHA1WithRSA 对第二步结果进行签名，结果如下 :\
  Dihl6oOt5UkaHo9sEouquP3EqbukLX2dAOoKTSGicYryTvH1m9r6vtSLHGutZn7u34/06gjhdpbXRFPdjb51GVHvG75qWXZ1P/boL89xtuja6eTEy9q/aS8R270Q1A+m/MOTxdiifCy0IByrSpCs4VJKaj2d8jlJo2GHznsH+q0=

## **2.附件说明**

**java** **版本** [**demo**](https://github.com/CTradeExchange/sign-demo)**.**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-cn.multimarkets.org/client-api/open-api/shuo-ming/qian-ming.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
