Webhook Sign

public class MerSignCheckUtil {

    private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5',
        '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };

    public static String getMerSign(String appId, String appSecret, String timestamp) {
        return encode("sha1", appId  + appSecret + timestamp);
    }


    private static String encode(String algorithm, String value) {
        if (value == null) {
            return null;
        }
        try {
            MessageDigest messageDigest
                = MessageDigest.getInstance(algorithm);
            messageDigest.update(value.getBytes());
            return getFormattedText(messageDigest.digest());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    private static String getFormattedText(byte[] bytes) {
        int len = bytes.length;
        StringBuilder buf = new StringBuilder(len * 2);
        for (int j = 0; j < len; j++) {
            buf.append(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]);
            buf.append(HEX_DIGITS[bytes[j] & 0x0f]);
        }
        return buf.toString();
    }
}


// 生成时间戳 和sign
public static void main(String[] args) {
        String signStrOnRamp = appId+orderNo+crypto+network+address;
        String signStrOffRamp = orderNo+crypto+network+address;
        System.out.println(MerSignCheckUtil.getMerSign("f83Is2**********", "4Yn*************", signStr)); 
    }
//node v14.15.1
const sha1 = require('js-sha1');

signStrOnRamp = appId+orderNo+crypto+network+address
signStrOffRamp = orderNo+crypto+network+address


function getMerSign(appId, appSecret, signStr) {
  return sha1(appId + appSecret + String(signStr));
}
#Python 3.7.4 
import hashlib
from time import time


def getMerSign(appId, appSecret, signStr):
    strr = appId + appSecret + signStr
    encoded_str = strr.encode()
    hash_obj = hashlib.sha1(encoded_str)
    hexa_value = hash_obj.hexdigest()
    return hexa_value


sign_str_OnRamp = appId+orderNo+crypto+network+address
sign_str_OffRamp = orderNo+crypto+network+address
res = getMerSign("f83Is2**********", "4Yn*************", signStr)
print(res)
//PHP 8.0.7
<?php
function getMerSign($appId, $appSecret, $timestamp){
  $str = $appId.$appSecret.strval($timestamp);
  return sha1($str);
}
$timestamp = floor(microtime(true) * 1000);
printf("timestamp = %d\n", $timestamp);
$res = getMerSign("f83Is2**********", "4Yn*************", $timestamp);
print($res);
 ?>
//go version go1.18.2
package main

import (
    "crypto/sha1"
    "encoding/hex"
    "strconv"
)

func getMerSign(appId string, appSecret string, timestamp int64) string {
    signStrOnRamp := appId+orderNo+crypto+network+address
    signStrOffRamp := orderNo+crypto+network+address

    s := appId + appSecret + signStr
    h := sha1.New()
    h.Write([]byte(s))
    //io.WriteString(h, s)
    return hex.EncodeToString(h.Sum(nil))
}