# Code Encryption DEMO

Take JAVA language as an example, the Sha1 encryption algorithm is as follows. The code below can be tested using the following command on a machine configured with a java development environment (jdk>=1.8):

* javac Sha1Demo.java&#x20;
* java Sha1Demo

After executing the above command, we get the output: 0354980F3F1162CFD25C4BD3DE69E6D686D60722&#x20;

The Sha1Demo.java code is as follows:

```

import javax.xml.bind.DatatypeConverter;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;


public class Sha1Demo {

    public String sha1(String input) {
        String sha1 = null;
        try {
            MessageDigest msdDigest = MessageDigest.getInstance("SHA-1");
            msdDigest.update(input.getBytes("UTF-8"), 0, input.length());
            sha1 = DatatypeConverter.printHexBinary(msdDigest.digest());
        } catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return sha1;
    }

    public static void main(String[] args) {
        // Service order json example
        Map<String,String> map = new HashMap<>();
        // Message ID 
        map.put("msgId","1887f9fa2c23455b9501902ff3e89142");
        // Signature hash
        map.put("msgSignature","0354980F3F1162CFD25C4BD3DE69E6D686D60722");
        // Message Type 
        map.put("msgType","event.autox3.order.receivebase.create");
        // Staff Info 
        map.put("staffInfo","{\"areaCode\":\"+44\",\"brandId\":134,\"mobile\":\"13601190376\",\"staffId\":400,\"staffName\":\"James Anderson\",\"storeId\":91}");
        // Push time 
        map.put("createTime","1622452772343");
        // Message content
        map.put("content","{\"carInfo\":{\"carBrandName\":\"Alpha Romeo\",\"carNum\":\"JS73RHK\",\"carOwnerFirstName\":\"\",\"carOwnerLastName\":\"Thomson\",\"carOwnerMobile\":\"\",\"carProductionDate\":1325347200000,\"carStyleName\":\"ALFA 156\",\"carVin\":\"\",\"salutation\":\"Mr.\"},\"preServiceInspection\":{\"mileage\":1653.0,\"personalItemList\":[]},\"serviceOrderId\":7591}");

        String appSecret = "084336629F874E793035255E12E88DAE87556274D860432BBB21A93951B9F98E";
        String text = map.get("msgId") + map.get("msgType") + map.get("staffInfo")
                + map.get("createTime") +  map.get("content") + appSecret;
        System.out.println(new Sha1Demo().sha1(text));
    }
}
```


---

# 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://autox3api.gitbook.io/autox3/faq/code-encryption-demo.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.
