> For the complete documentation index, see [llms.txt](https://gitbook.umiverse.io/sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.umiverse.io/sdk/signature/java.md).

# Java

```java
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
import java.util.TreeMap;

public class SignGenerator {
    public static String generateSign(Map<String, String> params, String secretKey) throws NoSuchAlgorithmException {
        long timestamp = System.currentTimeMillis() / 1000L;
        Map<String, String> sortedParams = new TreeMap<>(params);
        sortedParams.put("timestamp", Long.toString(timestamp));
        StringBuilder signStr = new StringBuilder();
        for (Map.Entry<String, String> entry : sortedParams.entrySet()) {
            signStr.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
        }
        signStr.append(secretKey);
        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] digest = md.digest(signStr.toString().getBytes());
        StringBuilder sign = new StringBuilder();
        for (byte b : digest) {
            sign.append(String.format("%02x", b & 0xff));
        }
        return sign.toString();
    }
}
```

In this implementation, the `generateSign` function takes a `Map` of parameters and a `String` secret key as input. It generates a timestamp using `System.currentTimeMillis()`, sorts the parameters using a `TreeMap`, and adds the timestamp to the sorted parameters. It then concatenates the sorted parameters and the secret key into a string, computes the MD5 hash of the resulting string, and returns the hash as a string.<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://gitbook.umiverse.io/sdk/signature/java.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.
