实现签署回调功能
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.ruoyi.wisdomarbitrate.utils;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class DigesdateUtils {
|
||||
|
||||
public static String getSignStr(String paramsStr, String accessSec ) {
|
||||
Mac macDiges = null;
|
||||
try {
|
||||
macDiges = Mac.getInstance("HmacSHA256");
|
||||
SecretKeySpec accessSecKey = new SecretKeySpec(accessSec.getBytes("UTF-8"), "HmacSHA256");
|
||||
macDiges.init(accessSecKey);
|
||||
macDiges.update(paramsStr.getBytes("UTF-8"));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (InvalidKeyException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return byteTrasferhex(macDiges.doFinal());
|
||||
}
|
||||
|
||||
public static String byteTrasferhex(byte[] byteArrayData) {
|
||||
StringBuilder hashBuilder = new StringBuilder();
|
||||
String stmpHex;
|
||||
for (int n = 0; byteArrayData != null && n < byteArrayData.length; n++) {
|
||||
stmpHex = Integer.toHexString(byteArrayData[n] & 0XFF);
|
||||
if (stmpHex.length() == 1){
|
||||
hashBuilder.append('0');
|
||||
}else {
|
||||
hashBuilder.append(stmpHex);
|
||||
}
|
||||
}
|
||||
return hashBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user