A Python program that generates MD5 signatures for HikIOT requests data.
The HTTP request body should be as follows, and the header contains a MD5 key named 'sign'.
This signature function creates a unique hash by sorting an input dictionary's keys, concatenating the key-value pairs into a string, and applying MD5 hashing twice. First, it generates an MD5 hash from the concatenated string. Then, it combines this hash (in uppercase) with a fixed salt string and hashes it again, returning the final result in uppercase.
The salt used for encryption may change in subsequent version updates. Welcome to Pull Requests and improve this project together.
Pass the JSON data you need to send into the get_sign function, and then return the signature.
from hikiot_sign import get_sign
data = {
"deviceSerial": "",
"longitude": xxx,
"latitude": xxx,
"clockSite": "xxx",
"address": "xxx",
"deviceName": "xxx",
"wifiName": "xxx",
"wifiMac": "xxx"
}
data_sign = get_sign(data)
This repo also provides a demo Flask API server in demo_server.py
. You can build your own backend server.