# 签名

### 签名规则：

&#x20;1：签名中出现&，为连接符，非运算符，签名规则：body体中signature不参与签名，但header中的timestamp参与body签名&#x20;

2：其余以参数名的字典升序排序（ascii码升序），且值不为空，并拼接"key=value"格式，多参数之间以&链接，得到A 值为空，不参与签名 只有数字类型以及字符串类型,参与签名&#x20;

3：timestamp=时间戳，得到B，然后B\&A得到C&#x20;

4：将C使用MD5加密并全部字母变为大写，得到最终值D，即为signature值&#x20;

5：body中需要增加signature，然后对body中数据，转为json后，进行encode转码，得到E&#x20;

6：用公司公钥将E进行加密，得到F，其请求key值为data F长度以100长度分割，进行分段加密，加密后的值，需以用","进行拼接 7：最终请求参数结构如下：

```json
//请求header
{
    "timestamp": 11111131331,
    "trace": "xxxxxx"
}

//请求body
{
    "data": F
}
```

### 签名示例：

1：a=1\&b=2\&c=3\&timestamp=11111131331，即为A&#x20;

2：timestamp=11111131331，即为B&#x20;

3: A\&B 即 timestamp=11111131331\&a=1\&b=2\&c=3\&timestamp=11111131331 为最终C取值&#x20;

4：将C进行MD5加密并全部字母变为大写，得到最终签名密钥&#x20;

5：对所有body参数，转为json后，encode转码，得到E&#x20;

6：RSA加密 用公司公钥将E加密，得到F 若E长度>100,则RSA(E\[0-100])=E1,RSA\[E\[剩余长度]]=E2，最终F=E1,E2

> 增加签名后的内容：

```json
//请求header
{
   "timestamp": 11111131331,
   "trace": "xxxxxx"
}

//请求body
{
   "a": 1,
   "b": 2,
   "c": "3",
   "signature": "44b3a042-dd5d-4796-92e1-651927b6ada9"
}
```

> 参数加密后的内容：

```json
//请求header
{
    "timestamp": 11111131331,
    "trace": "xxxxxx"
}

//请求body
{
    "data": F
}
```

### JAVA DEMO

<https://github.com/CTradeExchange/multimarket-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/jie-ru-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.
