全所统计
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.jero.util;
|
||||
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.RSA;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.util.RestUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
/**
|
||||
* @author liJiaRao
|
||||
* @date 2021-09-10 9:58
|
||||
*/
|
||||
public class standardsUtil {
|
||||
@Value("${standards.url}")
|
||||
private static String url;
|
||||
@Value("${standards.token}")
|
||||
private static String token;
|
||||
|
||||
public static String getRSAPublicKey(){
|
||||
JSONObject jsonObject = RestUtil.get(url + "/sys/getRSAPublicKey");
|
||||
if (jsonObject.getBoolean("success")) {
|
||||
return jsonObject.getString("result");
|
||||
}else {
|
||||
throw new JeroBootException("调用会员系统出错");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* RSA 使用公钥加密token
|
||||
* @param RSAPublicKey 公钥
|
||||
* @return String 加密后的字符串
|
||||
*/
|
||||
public static String encryptByRsaPriKey(String RSAPublicKey) {
|
||||
RSA rsa = new RSA(null, RSAPublicKey);
|
||||
byte[] encrypt = rsa.encrypt(token, KeyType.PublicKey);
|
||||
return new String(encrypt);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user