Signature Description

Introduction

SHA1(appId + appSecret + timestamp), perform SHA1 hash calculation on the concatenated string of the three parameters to generate hexadecimal characters.

Example of Signature Generation

package treasury;

import java.security.MessageDigest;
import java.math.BigInteger;

public class sha1 {
    public static void main(String[] args) throws Exception {
        // Parameters
        String appId = "***";       
        String appSecret = "***";   

        // timestamp
        long timestamp = System.currentTimeMillis();
        System.out.println("Timestamp: " + timestamp);

        // Concatenate the parameters into a single string
        String stringToHash = appId + appSecret + timestamp;
        System.out.println("sign Content (before hashing): " + stringToHash);

        // Generate SHA1 hash
        MessageDigest digest = MessageDigest.getInstance("SHA-1");
        byte[] hashBytes = digest.digest(stringToHash.getBytes("UTF-8"));
        String hash = String.format("%040x", new BigInteger(1, hashBytes));

        System.out.println("Generated sign: " + hash);
    }
}
const crypto = require('crypto');

function generateSHA1Signature(appId, appSecret) {
    // timestamp
    const timestamp = Date.now();
    console.log("Timestamp: " + timestamp);

    // Concatenate the parameters into a single string
    const stringToHash = appId + appSecret + timestamp;
    console.log("sign Content (before hashing): " + stringToHash);

    // Generate SHA1 hash
    const hash = crypto.createHash('sha1').update(stringToHash).digest('hex');

    console.log("Generated sign: " + hash);
}

// Example usage
const appId = "***";
const appSecret = "***";
generateSHA1Signature(appId, appSecret);
<?php

// Parameters
$appId = "***";       // appId
$appSecret = "***";    // appSecret

// timestamp
$timestamp = strval(time() * 1000);
echo "Timestamp: " . $timestamp . PHP_EOL;

// Concatenate the parameters into a single string
$stringToHash = $appId . $appSecret . $timestamp;
echo "sign Content (before hashing): " . $stringToHash . PHP_EOL;

// Generate SHA1 hash
$hash = sha1($stringToHash);

echo "Generated sign: " . $hash;

?>