Commit fd189a5a authored by wujiang's avatar wujiang

提交代码

parent ff1ee801
...@@ -24,21 +24,26 @@ ...@@ -24,21 +24,26 @@
<artifactId>taos-jdbcdriver</artifactId> <artifactId>taos-jdbcdriver</artifactId>
<version>3.2.4</version> <version>3.2.4</version>
</dependency> </dependency>
<!-- <dependency> <!-- <dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.70</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.70</version>
</dependency>-->
<dependency>
<groupId>org.bouncycastle</groupId> <groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk16</artifactId> <artifactId>bcprov-jdk15on</artifactId>
<version>1.46</version> <version>1.70</version>
</dependency> </dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.16</version>
</dependency>-->
<!-- <dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.70</version>
</dependency>-->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk16</artifactId>
<version>1.46</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId> <artifactId>spring-mock</artifactId>
...@@ -47,7 +52,7 @@ ...@@ -47,7 +52,7 @@
</dependency> </dependency>
</dependencies> </dependencies>
<!-- <dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.bouncycastle</groupId> <groupId>org.bouncycastle</groupId>
...@@ -60,5 +65,5 @@ ...@@ -60,5 +65,5 @@
<version>1.70</version> <version>1.70</version>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement>--> </dependencyManagement>
</project> </project>
...@@ -60,6 +60,7 @@ public class HygfIcbcRecordExportDTO { ...@@ -60,6 +60,7 @@ public class HygfIcbcRecordExportDTO {
@ApiModelProperty (value = "聚富通电子账户账号") @ApiModelProperty (value = "聚富通电子账户账号")
private String mediumId; private String mediumId;
/** /**
* 开户状态, 00-初始,01-开户中,02-开户成功,03-开户失败 * 开户状态, 00-初始,01-开户中,02-开户成功,03-开户失败
*/ */
...@@ -87,5 +88,11 @@ public class HygfIcbcRecordExportDTO { ...@@ -87,5 +88,11 @@ public class HygfIcbcRecordExportDTO {
@ApiModelProperty (value = "最后扣款成功时间") @ApiModelProperty (value = "最后扣款成功时间")
private String paymentTime; private String paymentTime;
@ExcelProperty(value = "银行卡类型", index = 9)
@ApiModelProperty (value = "银行卡类型")
private String type;
@ExcelProperty(value = "可用余额", index = 10)
@ApiModelProperty (value = "可用余额")
private String holdBalance;
} }
\ No newline at end of file
...@@ -305,7 +305,8 @@ ...@@ -305,7 +305,8 @@
END END
) AS openAccountStatus, ) AS openAccountStatus,
pa.paymentAmount AS paymentAmount, pa.paymentAmount AS paymentAmount,
MAX(pa.payTime) paymentTime MAX(pa.payTime) paymentTime,
MAX(re.type) AS type
FROM FROM
`hygf_peasant_household` ph `hygf_peasant_household` ph
LEFT JOIN LEFT JOIN
......
...@@ -188,13 +188,13 @@ ...@@ -188,13 +188,13 @@
SELECT SELECT
COUNT( * ) AS total, COUNT( * ) AS total,
CASE WHEN grid_status = '1' THEN '待登记' CASE WHEN grid_status = '1' THEN '待登记'
WHEN grid_status = '2' THEN '审核中' WHEN grid_status = '2' THEN '经销商管理员待审核'
WHEN grid_status = '3' THEN '已完成' WHEN grid_status = '3' THEN '已完成'
WHEN grid_status = '4' THEN '未通过' WHEN grid_status = '4' THEN '未通过'
WHEN grid_status = '5' THEN '审核中' WHEN grid_status = '5' THEN '设计待审核'
WHEN grid_status = '6' THEN '审核中' WHEN grid_status = '6' THEN '设计待审核/工程待审核'
WHEN grid_status = '7' THEN '审核中' WHEN grid_status = '7' THEN '片区运营待审核'
WHEN grid_status = '8' THEN '审核中' WHEN grid_status = '8' THEN '工程待审核'
WHEN grid_status = '9' THEN '整改待审核' WHEN grid_status = '9' THEN '整改待审核'
ELSE '待整改' END AS statusText, ELSE '待整改' END AS statusText,
ROUND(COALESCE(SUM(ei.real_scale), 0), 2) AS realScale ROUND(COALESCE(SUM(ei.real_scale), 0), 2) AS realScale
...@@ -229,15 +229,15 @@ ...@@ -229,15 +229,15 @@
COUNT(*) AS total, COUNT(*) AS total,
CASE CASE
WHEN acceptance_check_status = '15' THEN '待提交' WHEN acceptance_check_status = '15' THEN '待提交'
WHEN acceptance_check_status = '2' THEN '审核中' WHEN acceptance_check_status = '2' THEN '经销商管理员待审核'
WHEN acceptance_check_status = '3' THEN '已完成' WHEN acceptance_check_status = '3' THEN '已完成'
WHEN acceptance_check_status = '4' THEN '未通过' WHEN acceptance_check_status = '4' THEN '未通过'
WHEN acceptance_check_status = '7' THEN '审核中' WHEN acceptance_check_status = '7' THEN '片区运营待审核'
WHEN acceptance_check_status = '9' THEN '整改待审核' WHEN acceptance_check_status = '9' THEN '整改待审核'
WHEN acceptance_check_status = '11' THEN '审核中' WHEN acceptance_check_status = '11' THEN '投融待审核/法务待审核'
WHEN acceptance_check_status = '12' THEN '审核中' WHEN acceptance_check_status = '12' THEN '投融待审核'
WHEN acceptance_check_status = '13' THEN '审核中' WHEN acceptance_check_status = '13' THEN '资产待审核'
WHEN acceptance_check_status = '14' THEN '审核中' WHEN acceptance_check_status = '14' THEN '法务待审核'
ELSE '待整改' ELSE '待整改'
END AS statusText, END AS statusText,
ROUND(COALESCE(SUM(ei.real_scale), 0), 2) AS realScale ROUND(COALESCE(SUM(ei.real_scale), 0), 2) AS realScale
......
...@@ -142,12 +142,6 @@ ...@@ -142,12 +142,6 @@
<artifactId>easypoi-annotation</artifactId> <artifactId>easypoi-annotation</artifactId>
<version>3.2.0</version> <version>3.2.0</version>
</dependency> </dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.16</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -19,8 +19,11 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -19,8 +19,11 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
/** /**
...@@ -153,7 +156,7 @@ public class HygfIcbcController extends BaseController { ...@@ -153,7 +156,7 @@ public class HygfIcbcController extends BaseController {
@ApiOperation(httpMethod = "GET",value = "聚富通信息", notes = "聚富通信息") @ApiOperation(httpMethod = "GET",value = "聚富通信息", notes = "聚富通信息")
@GetMapping(value = "/exportExcel") @GetMapping(value = "/exportExcel")
@UserLimits @UserLimits
public void exportData( HttpServletResponse response,HygfIcbcRecordQueryDTO hygfIcbcRecordQueryDTO) { public void exportData( HttpServletResponse response,HygfIcbcRecordQueryDTO hygfIcbcRecordQueryDTO) throws ExecutionException, InterruptedException {
hygfIcbcService.exportExcel(response,hygfIcbcRecordQueryDTO); hygfIcbcService.exportExcel(response,hygfIcbcRecordQueryDTO);
} }
...@@ -181,7 +184,18 @@ public class HygfIcbcController extends BaseController { ...@@ -181,7 +184,18 @@ public class HygfIcbcController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "余额查询", notes = "余额查询") @ApiOperation(httpMethod = "GET",value = "余额查询", notes = "余额查询")
@GetMapping(value = "/balanceQuery") @GetMapping(value = "/balanceQuery")
public ResponseModel<Object> balanceQuery(@RequestParam(required = true)String mediumId){ public ResponseModel<Object> balanceQuery(@RequestParam(required = true)String mediumId) throws ExecutionException, InterruptedException {
// List<CompletableFuture<Void>> futures = new ArrayList<>();
// for(int i =0;i<=1000;i++)
// {
// CompletableFuture<Void> fan = CompletableFuture.supplyAsync(() -> {
// hygfIcbcService.balanceQuery(mediumId);
// return null;
// });
// futures.add(fan);
// }
// CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).get();
return ResponseHelper.buildResponse(hygfIcbcService.balanceQuery(mediumId)); return ResponseHelper.buildResponse(hygfIcbcService.balanceQuery(mediumId));
} }
......
...@@ -8,16 +8,10 @@ import java.text.SimpleDateFormat; ...@@ -8,16 +8,10 @@ import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Arrays; import java.util.*;
import java.util.Base64; import java.util.concurrent.CompletableFuture;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -110,10 +104,7 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -110,10 +104,7 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
private String OUT_VENDOR_ID; private String OUT_VENDOR_ID;
@Value("${hygf.icbc.projectId}") @Value("${hygf.icbc.projectId}")
private String PROJECT_ID; private String PROJECT_ID;
@Value("${hygf.icbc.sm2PublicKey}")
private String SM2_PUBLIC_KEY;
@Value("${hygf.icbc.sm2PrivateKey}")
private String SM2_PRIVATE_KEY;
/** /**
* 协议总限额 * 协议总限额
*/ */
...@@ -695,8 +686,25 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -695,8 +686,25 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
} }
public void exportExcel(HttpServletResponse response, HygfIcbcRecordQueryDTO hygfIcbcRecordQueryDTO) { public void exportExcel(HttpServletResponse response, HygfIcbcRecordQueryDTO hygfIcbcRecordQueryDTO) throws ExecutionException, InterruptedException {
List<HygfIcbcRecordExportDTO> hygfIcbcRecordExportDTOS = hygfIcbcRecordMapper.paymentAmountExport(hygfIcbcRecordQueryDTO); List<HygfIcbcRecordExportDTO> hygfIcbcRecordExportDTOS = hygfIcbcRecordMapper.paymentAmountExport(hygfIcbcRecordQueryDTO);
List<CompletableFuture<Void>> futures = new ArrayList<>();
for(HygfIcbcRecordExportDTO dto : hygfIcbcRecordExportDTOS)
{
if(dto.getMediumId()!=null&&"二类卡".equals(dto.getType()))
{
CompletableFuture<Void> fan = CompletableFuture.supplyAsync(() -> {
SettlementAccountBalanceQueryResponseV1 res= (SettlementAccountBalanceQueryResponseV1) this.balanceQuery(dto.getMediumId());
if(res.isSuccess())
{
dto.setHoldBalance(res.getHoldBalance());
}
return null;
});
futures.add(fan);
}
}
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).get();
if (CollectionUtil.isNotEmpty(hygfIcbcRecordExportDTOS)) { if (CollectionUtil.isNotEmpty(hygfIcbcRecordExportDTOS)) {
ExcelUtil.createTemplate(response, "账号信息", "账号信息", hygfIcbcRecordExportDTOS, HygfIcbcRecordExportDTO.class, null, false); ExcelUtil.createTemplate(response, "账号信息", "账号信息", hygfIcbcRecordExportDTOS, HygfIcbcRecordExportDTO.class, null, false);
} }
...@@ -909,11 +917,14 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -909,11 +917,14 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
} }
public Object balanceQuery(String mediumId) { public Object balanceQuery(String mediumId) {
DefaultIcbcClient client = new DefaultIcbcClient(APP_ID, IcbcConstants.SIGN_TYPE_RSA2, MY_PRIVATE_KEY, DefaultIcbcClient client = new DefaultIcbcClient(APP_ID, IcbcConstants.SIGN_TYPE_RSA2, MY_PRIVATE_KEY,
IcbcConstants.CHARSET_UTF8, IcbcConstants.FORMAT_JSON, APIGW_PUBLIC_KEY, IcbcConstants.ENCRYPT_TYPE_AES, IcbcConstants.CHARSET_UTF8, IcbcConstants.FORMAT_JSON, APIGW_PUBLIC_KEY, IcbcConstants.ENCRYPT_TYPE_AES,
AES_Key, "", ""); AES_Key, "", "");
SettlementAccountBalanceQueryRequestV1 request = new SettlementAccountBalanceQueryRequestV1(); SettlementAccountBalanceQueryRequestV1 request = new SettlementAccountBalanceQueryRequestV1();
String apiUrl = serviceUrl + "/api/settlement/account/balance/V1/query"; String apiUrl = serviceUrl + "/api/settlement/account/balance/V1/query";
// String apiUrl = serviceUrl + "/api/settlement/ /balance/query/V2";
request.setServiceUrl(apiUrl); request.setServiceUrl(apiUrl);
SettlementAccountBalanceQueryRequestV1.SettlementAccountBalanceQueryRequestV1Biz bizContent = new SettlementAccountBalanceQueryRequestV1.SettlementAccountBalanceQueryRequestV1Biz(); SettlementAccountBalanceQueryRequestV1.SettlementAccountBalanceQueryRequestV1Biz bizContent = new SettlementAccountBalanceQueryRequestV1.SettlementAccountBalanceQueryRequestV1Biz();
bizContent.setCorpNo(corpNo);//合作方机构编号 bizContent.setCorpNo(corpNo);//合作方机构编号
...@@ -929,7 +940,8 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -929,7 +940,8 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
bizContent.setOutServiceCode("querybalance");//外部服务代码 bizContent.setOutServiceCode("querybalance");//外部服务代码
//String encodedString = Base64.getEncoder().encodeToString(mediumId.getBytes()); //String encodedString = Base64.getEncoder().encodeToString(mediumId.getBytes());
//生成sm4密钥 //生成sm4密钥
String origSecretKey = UtilIcbc.getNonceStr(16); //String origSecretKey = UtilIcbc.getNonceStr(16);
String origSecretKey ="1234567890123456";
String secretKey = UtilIcbc.getHexString(origSecretKey.getBytes()); String secretKey = UtilIcbc.getHexString(origSecretKey.getBytes());
SM4Utils.secretKey = secretKey; SM4Utils.secretKey = secretKey;
SM4Utils.hexString = true; SM4Utils.hexString = true;
...@@ -937,14 +949,18 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc ...@@ -937,14 +949,18 @@ public class HygfIcbcServiceImpl extends BaseService<HygfIcbcRecordDTO, HygfIcbc
//生成sm2加密后的sm4公钥 //生成sm2加密后的sm4公钥
String sm4SecretKey = null; String sm4SecretKey = null;
try { try {
sm4SecretKey = SM2Utils.encrypt(UtilIcbc.hexToByte(SM2_PUBLIC_KEY), origSecretKey.getBytes()); sm4SecretKey = SM2Utils.encrypt(UtilIcbc.hexToByte("04"+CAMS_PUBLIC_KEY), origSecretKey.getBytes());
// sm4SecretKey = SM2Utils.encrypt(UtilIcbc.hexToByte(SM2_PUBLIC_KEY), origSecretKey.getBytes());
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
// sm4SecretKey= Sm2Util.encryptBase64(origSecretKey,"04"+CAMS_PUBLIC_KEY);
//私钥解密
//String des = Sm2Util.decryptBase64(sm4SecretKey,SM2_PRIVATE_KEY);
//涉密信息如身份证号,姓名,卡号都需要用sm4密钥进行加密 //涉密信息如身份证号,姓名,卡号都需要用sm4密钥进行加密
bizContent.setMediumId(SM4Utils.encryptData_CBC(mediumId)); //工行联名卡号 bizContent.setMediumId(SM4Utils.encryptData_CBC(mediumId)); //工行联名卡号
bizContent.setCcy(1); //币种,1 bizContent.setCcy(1); //币种,1
bizContent.setSecretKey(sm4SecretKey); // sm4对称密钥(对敏感信息加密时必送) bizContent.setSecretKey(sm4SecretKey);
request.setBizContent(bizContent); request.setBizContent(bizContent);
SettlementAccountBalanceQueryResponseV1 response = null; SettlementAccountBalanceQueryResponseV1 response = null;
try { try {
......
...@@ -272,8 +272,6 @@ hygf.icbc.camsPublicKey=655CE8706E6ED9A30B92E57D8D645ADDE8C541C27C5C5AFD529C610C ...@@ -272,8 +272,6 @@ hygf.icbc.camsPublicKey=655CE8706E6ED9A30B92E57D8D645ADDE8C541C27C5C5AFD529C610C
hygf.icbc.apigwPublicKey=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMpjaWjngB4E3ATh+G1DVAmQnIpiPEFAEDqRfNGAVvvH35yDetqewKi0l7OEceTMN1C6NPym3zStvSoQayjYV+eIcZERkx31KhtFu9clZKgRTyPjdKMIth/wBtPKjL/5+PYalLdomM4ONthrPgnkN4x4R0+D4+EBpXo8gNiAFsNwIDAQAB hygf.icbc.apigwPublicKey=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMpjaWjngB4E3ATh+G1DVAmQnIpiPEFAEDqRfNGAVvvH35yDetqewKi0l7OEceTMN1C6NPym3zStvSoQayjYV+eIcZERkx31KhtFu9clZKgRTyPjdKMIth/wBtPKjL/5+PYalLdomM4ONthrPgnkN4x4R0+D4+EBpXo8gNiAFsNwIDAQAB
hygf.icbc.outVendorId=gxjr hygf.icbc.outVendorId=gxjr
hygf.icbc.projectId=PJ140014023565102203 hygf.icbc.projectId=PJ140014023565102203
hygf.icbc.sm2PublicKey=04724755085cda47d161e4e1db0b4699521dcc0411fd34957457e9175b193ae6bf339e4c7a27e96d448f59073130c80efe1c6c0722c0f8c996567b31ead9f0f06e
hygf.icbc.sm2PrivateKey=807e5dcea2bb31f7846aa2bcc5211ed5903bfb718f4817abab3590058a71a915
icbc.Withhold.projectId=PJ140014023565102203 icbc.Withhold.projectId=PJ140014023565102203
......
...@@ -49,11 +49,11 @@ ...@@ -49,11 +49,11 @@
<version>5.7.22</version> <version>5.7.22</version>
</dependency> </dependency>
<dependency> <!-- <dependency>
<groupId>org.bouncycastle</groupId> <groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15to18</artifactId> <artifactId>bcprov-jdk15to18</artifactId>
<version>1.69</version> <version>1.69</version>
</dependency> </dependency>-->
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.influxdb</groupId>--> <!-- <groupId>org.influxdb</groupId>-->
<!-- <artifactId>influxdb-java</artifactId>--> <!-- <artifactId>influxdb-java</artifactId>-->
......
...@@ -5,14 +5,14 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,14 +5,14 @@ import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.NeedDataVO; import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.NeedDataVO;
import com.yeejoin.amos.component.robot.AmosRequestContext; import com.yeejoin.amos.component.robot.AmosRequestContext;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.asn1.gm.GMNamedCurves; //import org.bouncycastle.asn1.gm.GMNamedCurves;
import org.bouncycastle.asn1.x9.X9ECParameters; //import org.bouncycastle.asn1.x9.X9ECParameters;
import org.bouncycastle.crypto.engines.SM2Engine; //import org.bouncycastle.crypto.engines.SM2Engine;
import org.bouncycastle.crypto.params.ECDomainParameters; //import org.bouncycastle.crypto.params.ECDomainParameters;
import org.bouncycastle.crypto.params.ECPublicKeyParameters; //import org.bouncycastle.crypto.params.ECPublicKeyParameters;
import org.bouncycastle.crypto.params.ParametersWithRandom; //import org.bouncycastle.crypto.params.ParametersWithRandom;
import org.bouncycastle.math.ec.ECPoint; //import org.bouncycastle.math.ec.ECPoint;
import org.bouncycastle.util.encoders.Hex; //import org.bouncycastle.util.encoders.Hex;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*; import org.springframework.http.*;
...@@ -49,24 +49,25 @@ public class JXDZUtils { ...@@ -49,24 +49,25 @@ public class JXDZUtils {
public static String GF_CODE="PPC17063608260011"; public static String GF_CODE="PPC17063608260011";
private String dataEncrypt(String obj, String publicKey) { private String dataEncrypt(String obj, String publicKey) {
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1"); // X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(), sm2ECParameters.getG(), // ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(), sm2ECParameters.getG(),
sm2ECParameters.getN(), sm2ECParameters.getH()); // sm2ECParameters.getN(), sm2ECParameters.getH());
ECPoint pukPoint = sm2ECParameters.getCurve() // ECPoint pukPoint = sm2ECParameters.getCurve()
.decodePoint(Hex.decode(publicKey)); // .decodePoint(Hex.decode(publicKey));
ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(pukPoint, domainParameters); // ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(pukPoint, domainParameters);
SM2Engine.Mode mode = SM2Engine.Mode.C1C3C2; // SM2Engine.Mode mode = SM2Engine.Mode.C1C3C2;
SM2Engine sm2Engine = new SM2Engine(mode); // SM2Engine sm2Engine = new SM2Engine(mode);
// 设置sm2为加密模式 // // 设置sm2为加密模式
sm2Engine.init(true, new ParametersWithRandom(publicKeyParameters, new SecureRandom())); // sm2Engine.init(true, new ParametersWithRandom(publicKeyParameters, new SecureRandom()));
byte[] arrayOfBytes = null; // byte[] arrayOfBytes = null;
byte[] in = obj.getBytes(StandardCharsets.UTF_8); // byte[] in = obj.getBytes(StandardCharsets.UTF_8);
try { // try {
arrayOfBytes = sm2Engine.processBlock(in, 0, in.length); // arrayOfBytes = sm2Engine.processBlock(in, 0, in.length);
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
return Base64.encode(arrayOfBytes); // return Base64.encode(arrayOfBytes);
return null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment