• pom引入依bouncycastle赖
    注意:bouncycastle版本过低会出现报错(我之前报错的的版本号1.60,修改后使用的1.68)
<dependency><groupId>org.bouncycastle</groupId><artifactId>bcprov-ext-jdk15to18</artifactId><version>1.68</version>
</dependency>
<dependency><groupId>org.bouncycastle</groupId><artifactId>bcprov-jdk15to18</artifactId><version>1.68</version>
</dependency>
  • 初始化密钥对
private static void initKeyBase64() {// 创建 sm2 对象SM2 sm2 = SmUtil.sm2();// 这里会自动生成对应的随机秘钥对 , 注意! 这里一定要强转,才能得到对应有效的秘钥信息byte[] privateKey = BCUtil.encodeECPrivateKey(sm2.getPrivateKey());// 这里公钥不压缩 公钥的第一个字节用于表示是否压缩 可以不要byte[] publicKey = ((BCECPublicKey) sm2.getPublicKey()).getQ().getEncoded(false);// 打印当前的公私秘钥System.out.println("SM2 公钥(HEX): " + HexUtil.encodeHexStr(publicKey));System.out.println("SM2 公钥长度(HEX): " + HexUtil.encodeHexStr(publicKey).length());System.out.println("SM2 公钥(BASE64): " + Base64.encodeBase64String(publicKey));System.out.println("SM2 公钥长度(BASE64): " + Base64.encodeBase64String(publicKey).length());System.out.println("SM2 私钥(HEX): " + HexUtil.encodeHexStr(privateKey));System.out.println("SM2 私钥公钥长度(HEX): " + HexUtil.encodeHexStr(privateKey).length());System.out.println("SM2 私钥(BASE64): " + Base64.encodeBase64String(privateKey));System.out.println("SM2 私钥长度(BASE64): " + Base64.encodeBase64String(privateKey).length());
}
  • 加密
public static String cmbSM2Encrypt(String sPubKey, String pladat, String charset) {if (null == charset || !GBK.equalsIgnoreCase(charset)) {charset = UTF_8;}if (StringUtils.isEmpty(pladat)) {throw new BusinessException("TYSM208", "原文为空");}try {byte[] pubkey = Base64.decodeBase64(sPubKey);byte[] msg = pladat.getBytes(charset);byte[] resBt = cmbSM2Encrypt(pubkey, msg);return Base64.encodeBase64String(resBt);} catch (Exception ex) {System.out.println("SM4Tool.CMBEecrypt error:" + ex);throw new BusinessException("加密异常:" + ex.getMessage(), "TYSM209");}
}private static byte[] cmbSM2Encrypt(byte[] pubkey, byte[] msg) {if (pubkey == null || msg == null || msg.length == 0) {throw new BusinessException("请求参数不合法", "TYSM211");} else if (pubkey.length != 65) {throw new BusinessException("公钥非法", "TYSM212");} else if (pubkey[0] != 4) {throw new BusinessException("公钥非法", "TYSM213");} else {ECPublicKeyParameters publicKey = null;try {publicKey = encodePublicKey(pubkey);} catch (Exception var7) {throw new BusinessException("公钥非法", "TYSM214");}SM2Engine engine = new SM2Engine();engine.init(true, new ParametersWithRandom(publicKey, new SecureRandom()));try {byte[] cipherText = engine.processBlock(msg, 0, msg.length);return C1C2C3ToC1C3C2(cipherText);} catch (InvalidCipherTextException var6) {throw new BusinessException("加密失败。", "TYSM215");}}
}
  • 解密
public static String cmbSM2Decrypt(String sPrvKeyStr, String strData, String charset) {if (null == charset || !GBK.equalsIgnoreCase(charset)) {charset = UTF_8;}if (StringUtils.isEmpty(strData)) {throw new BusinessException("密文为空", "TYSM206");}try {byte[] privkey = Base64.decodeBase64(sPrvKeyStr);byte[] msg = Base64.decodeBase64(strData);byte[] resBt = cmbSM2Decrypt(privkey, msg);return new String(resBt, charset);} catch (Exception ex) {System.out.println("SM4Tool.CMBDecrypt error:" + ex);throw new BusinessException("解密异常:" + ex.getMessage(), "TYSM207");}
}private static byte[] cmbSM2Decrypt(byte[] privkey, byte[] msg) {if (privkey == null || msg == null || privkey.length != 32) {throw new BusinessException("请求参数不合法", "TYSM216");} else if (msg.length < 97) {throw new BusinessException("密文有误", "TYSM217");} else if (msg[0] != 4) {throw new BusinessException("密文有误#2", "TYSM218");} else {msg = C1C3C2ToC1C2C3(msg);ECPrivateKeyParameters privateKey = null;try {privateKey = encodePrivateKey(privkey);} catch (Exception var7) {throw new BusinessException("TYSM219", "公钥错误");}SM2Engine engine = new SM2Engine();engine.init(false, privateKey);try {return engine.processBlock(msg, 0, msg.length);} catch (InvalidCipherTextException var6) {throw new BusinessException("TYSM220", "解密失败。");}}
}private static byte[] C1C3C2ToC1C2C3(byte[] cipherText) {if (cipherText != null && cipherText.length >= 97) {byte[] bytes = new byte[cipherText.length];System.arraycopy(cipherText, 0, bytes, 0, 65);System.arraycopy(cipherText, 97, bytes, 65, cipherText.length - 97);System.arraycopy(cipherText, 65, bytes, cipherText.length - 32, 32);return bytes;} else {throw new BusinessException("TYSM221", "密文有误#3");}
}
  • 加签
public static String cmbSM2Sign(String sPrivateKey, String sStrToSign, String doSM3, String charset) {if (StringUtils.isEmpty(sPrivateKey) || StringUtils.isEmpty(sStrToSign)) {throw new BusinessException("签名数据有误,请检查", "TYSM201");}if (!"gbk".equalsIgnoreCase(charset)) {charset = "utf-8";}try {byte[] privkey = Base64.decodeBase64(sPrivateKey);byte[] msg = "Y".equals(doSM3) ? CMBSM3Digest(sStrToSign.getBytes(charset)) : sStrToSign.getBytes(charset);ECPrivateKeyParameters privateKey = encodePrivateKey(privkey);SM2Signer signer = new SM2Signer();ParametersWithID parameters = new ParametersWithID(privateKey, USER_ID);signer.init(true, parameters);signer.update(msg, 0, msg.length);return Base64.encodeBase64String(decodeDERSignature(signer.generateSignature()));} catch (Exception var8) {throw new BusinessException("签名异常:" + var8.getMessage(), "TYSM202");}
}private static byte[] CMBSM3Digest(byte[] msg) {byte[]bytes = new byte[32];SM3Digest digest = new SM3Digest();digest.update(msg, 0, msg.length);digest.doFinal(bytes, 0);digest.reset();return bytes;
}private static ECPrivateKeyParameters encodePrivateKey(byte[] value) {BigInteger d = new BigInteger(1, value);return new ECPrivateKeyParameters(d, getECDomainParameters());
}private static ECDomainParameters getECDomainParameters() {ECParameterSpec spec = ECNamedCurveTable.getParameterSpec("sm2p256v1");return new ECDomainParameters(spec.getCurve(), spec.getG(), spec.getN(), spec.getH(), spec.getSeed());
}
  • 验签
public static Boolean cmbSM2Verify(String sPubKey, String strToSign, String strSign, String doSM3, String charset) {if (!GBK.equalsIgnoreCase(charset)) {charset = UTF_8;}try {byte[] pubKeys = Base64.decodeBase64(sPubKey);byte[] byteBuffer = "Y".equals(doSM3) ? CMBSM3Digest(strToSign.getBytes(charset)) : strToSign.getBytes(charset);byte[] signature = Base64.decodeBase64(strSign);ECPublicKeyParameters publicKey = encodePublicKey(pubKeys);SM2Signer signer = new SM2Signer();ParametersWithID parameters = new ParametersWithID(publicKey, USER_ID);signer.init(false, parameters);signer.update(byteBuffer, 0, byteBuffer.length);if (!signer.verifySignature(encodeDERSignature(signature))) {throw new BusinessException("请求签名校验不通过。", "TYSM204");}return true;} catch (Exception e) {if (e instanceof BusinessException) {throw (BusinessException) e;}System.out.println("Verify signature fail: " + e.getMessage());throw new BusinessException("请求签名校验失败。", "TYSM205");}
}private static ECPublicKeyParameters encodePublicKey(byte[] value) {byte[] x = new byte[32];byte[] y = new byte[32];System.arraycopy(value, 1, x, 0, 32);System.arraycopy(value, 33, y, 0, 32);BigInteger iX = new BigInteger(1, x);BigInteger iY = new BigInteger(1, y);ECPoint ecQ = getSM2Curve().createPoint(iX, iY);return new ECPublicKeyParameters(ecQ, getECDomainParameters());
}private static ECCurve getSM2Curve() {ECParameterSpec spec = ECNamedCurveTable.getParameterSpec("sm2p256v1");return spec.getCurve();
}private static ECDomainParameters getECDomainParameters() {ECParameterSpec spec = ECNamedCurveTable.getParameterSpec("sm2p256v1");return new ECDomainParameters(spec.getCurve(), spec.getG(), spec.getN(), spec.getH(), spec.getSeed());
}}
  • 测试
public static void main(String[] args) {//initKeyBase64();Map<String, String> map = new HashMap<>(3);map.put("mobile", "18468242454");map.put("skuCode", "sku2021001");//TODO 后面替换为真实的核心企业IDmap.put("coreId", "sku2021001");String data = JSON.toJSONString(map);String publicSecret = "BMTxlXewbroQEvkgEg41bzUfYE5TVQiBpd4yrOeBQ9Ck3Kj0gHxvGaKnjc4ECwwJ7lIHYwNoCkh6JzxX/3sQ36A=";System.out.println("公钥字符长度:" + publicSecret.length());String privateSecret = "NgQBMpptzmgbnl2/yp1xBz7iafpBsyFEpz5kqhdpLSk=";System.out.println("私钥字符长度:" + privateSecret.length());System.out.println("加密前的字符:" + data);//用对方给的公钥加密,然后传给对方//result:加密得到的数据String result = cmbSM2Encrypt(publicSecret, data, "UTF-8");System.out.println("加密得到的字符:" + result);//dt:对方数据解密都得到的原文String olData = cmbSM2Decrypt(privateSecret, result, "UTF-8");System.out.println("解密后的字符:" + olData);String signData = cmbSM2Sign(privateSecret, data, "Y", "UTF-8");System.out.println("签名得到的字符:" + signData);Boolean y = cmbSM2Verify(publicSecret, data, signData, "Y", "UTF-8");System.out.println("签名验证结果:" + y);
}
  • 全部代码
package com.***;public class SM2Utils {private static final String UTF_8 = "UTF-8";
private static final String GBK = "GBK";
private static final byte[] USER_ID = "1234567812345678".getBytes();/*** 使用SM2私钥进行签名** @param sPrivateKey:私钥字符串(BASE64)* @param sStrToSign:待签名数据* @param doSM3:是否通过SM3摘要器获取数据摘要* @param charset:字符集* @return* @throws BusinessException*/
public static String cmbSM2Sign(String sPrivateKey, String sStrToSign, String doSM3, String charset) {if (StringUtils.isEmpty(sPrivateKey) || StringUtils.isEmpty(sStrToSign)) {throw new BusinessException("签名数据有误,请检查", "TYSM201");}if (!"gbk".equalsIgnoreCase(charset)) {charset = "utf-8";}try {byte[] privkey = Base64.decodeBase64(sPrivateKey);byte[] msg = "Y".equals(doSM3) ? CMBSM3Digest(sStrToSign.getBytes(charset)) : sStrToSign.getBytes(charset);ECPrivateKeyParameters privateKey = encodePrivateKey(privkey);SM2Signer signer = new SM2Signer();ParametersWithID parameters = new ParametersWithID(privateKey, USER_ID);signer.init(true, parameters);signer.update(msg, 0, msg.length);return Base64.encodeBase64String(decodeDERSignature(signer.generateSignature()));} catch (Exception var8) {throw new BusinessException("签名异常:" + var8.getMessage(), "TYSM202");}
}/*** 验证签名* @param sPubKey:公钥字符串(BASE64)* @param strToSign:待验签数据* @param strSign:签名结果* @param doSM3:是否通过SM3摘要器获取数据摘要* @param charset:字符集* @throws BusinessException*/
public static Boolean cmbSM2Verify(String sPubKey, String strToSign, String strSign, String doSM3, String charset) {if (!GBK.equalsIgnoreCase(charset)) {charset = UTF_8;}try {byte[] pubKeys = Base64.decodeBase64(sPubKey);byte[] byteBuffer = "Y".equals(doSM3) ? CMBSM3Digest(strToSign.getBytes(charset)) : strToSign.getBytes(charset);byte[] signature = Base64.decodeBase64(strSign);ECPublicKeyParameters publicKey = encodePublicKey(pubKeys);SM2Signer signer = new SM2Signer();ParametersWithID parameters = new ParametersWithID(publicKey, USER_ID);signer.init(false, parameters);signer.update(byteBuffer, 0, byteBuffer.length);if (!signer.verifySignature(encodeDERSignature(signature))) {throw new BusinessException("请求签名校验不通过。", "TYSM204");}return true;} catch (Exception e) {if (e instanceof BusinessException) {throw (BusinessException) e;}System.out.println("Verify signature fail: " + e.getMessage());throw new BusinessException("请求签名校验失败。", "TYSM205");}
}/*** 使用SM2私钥进行解密** @return* @throws Exception*/
public static String cmbSM2Decrypt(String sPrvKeyStr, String strData, String charset) {if (null == charset || !GBK.equalsIgnoreCase(charset)) {charset = UTF_8;}if (StringUtils.isEmpty(strData)) {throw new BusinessException("密文为空", "TYSM206");}try {byte[] privkey = Base64.decodeBase64(sPrvKeyStr);byte[] msg = Base64.decodeBase64(strData);byte[] resBt = cmbSM2Decrypt(privkey, msg);return new String(resBt, charset);} catch (Exception ex) {System.out.println("SM4Tool.CMBDecrypt error:" + ex);throw new BusinessException("解密异常:" + ex.getMessage(), "TYSM207");}
}/*** 使用SM2公钥进行加密** @return* @throws Exception*/
public static String cmbSM2Encrypt(String sPubKey, String pladat, String charset) {if (null == charset || !GBK.equalsIgnoreCase(charset)) {charset = UTF_8;}if (StringUtils.isEmpty(pladat)) {throw new BusinessException("TYSM208", "原文为空");}try {byte[] pubkey = Base64.decodeBase64(sPubKey);byte[] msg = pladat.getBytes(charset);byte[] resBt = cmbSM2Encrypt(pubkey, msg);return Base64.encodeBase64String(resBt);} catch (Exception ex) {System.out.println("SM4Tool.CMBEecrypt error:" + ex);throw new BusinessException("加密异常:" + ex.getMessage(), "TYSM209");}
}private static byte[] cmbSM2Encrypt(byte[] pubkey, byte[] msg) {if (pubkey == null || msg == null || msg.length == 0) {throw new BusinessException("请求参数不合法", "TYSM211");} else if (pubkey.length != 65) {throw new BusinessException("公钥非法", "TYSM212");} else if (pubkey[0] != 4) {throw new BusinessException("公钥非法", "TYSM213");} else {ECPublicKeyParameters publicKey = null;try {publicKey = encodePublicKey(pubkey);} catch (Exception var7) {throw new BusinessException("公钥非法", "TYSM214");}SM2Engine engine = new SM2Engine();engine.init(true, new ParametersWithRandom(publicKey, new SecureRandom()));try {byte[] cipherText = engine.processBlock(msg, 0, msg.length);return C1C2C3ToC1C3C2(cipherText);} catch (InvalidCipherTextException var6) {throw new BusinessException("加密失败。", "TYSM215");}}
}private static byte[] cmbSM2Decrypt(byte[] privkey, byte[] msg) {if (privkey == null || msg == null || privkey.length != 32) {throw new BusinessException("请求参数不合法", "TYSM216");} else if (msg.length < 97) {throw new BusinessException("密文有误", "TYSM217");} else if (msg[0] != 4) {throw new BusinessException("密文有误#2", "TYSM218");} else {msg = C1C3C2ToC1C2C3(msg);ECPrivateKeyParameters privateKey = null;try {privateKey = encodePrivateKey(privkey);} catch (Exception var7) {throw new BusinessException("TYSM219", "公钥错误");}SM2Engine engine = new SM2Engine();engine.init(false, privateKey);try {return engine.processBlock(msg, 0, msg.length);} catch (InvalidCipherTextException var6) {throw new BusinessException("TYSM220", "解密失败。");}}
}private static byte[] C1C3C2ToC1C2C3(byte[] cipherText) {if (cipherText != null && cipherText.length >= 97) {byte[] bytes = new byte[cipherText.length];System.arraycopy(cipherText, 0, bytes, 0, 65);System.arraycopy(cipherText, 97, bytes, 65, cipherText.length - 97);System.arraycopy(cipherText, 65, bytes, cipherText.length - 32, 32);return bytes;} else {throw new BusinessException("TYSM221", "密文有误#3");}
}private static byte[] C1C2C3ToC1C3C2(byte[] cipherText) {if (cipherText != null && cipherText.length >= 97) {byte[] bytes = new byte[cipherText.length];System.arraycopy(cipherText, 0, bytes, 0, 65);System.arraycopy(cipherText, cipherText.length - 32, bytes, 65, 32);System.arraycopy(cipherText, 65, bytes, 97, cipherText.length - 97);return bytes;} else {throw new BusinessException("TYSM222", "密文有误#3");}
}private static byte[] decodeDERSignature(byte[] signature) {try (ASN1InputStream stream = new ASN1InputStream(new ByteArrayInputStream(signature))) {ASN1Sequence primitive = (ASN1Sequence) stream.readObject();Enumeration<ASN1Integer> enumeration = primitive.getObjects();BigInteger R = enumeration.nextElement().getValue();BigInteger S = enumeration.nextElement().getValue();byte[] bytes = new byte[64];byte[] r = format(R.toByteArray());byte[] s = format(S.toByteArray());System.arraycopy(r, 0, bytes, 0, 32);System.arraycopy(s, 0, bytes, 32, 32);return bytes;} catch (Exception var10) {throw new BusinessException("签名解析异常:" + var10.getMessage(), "TYSM223");}
}private static byte[] format(byte[] value) {if (value.length == 32) {return value;} else {byte[] bytes = new byte[32];if (value.length > 32) {System.arraycopy(value, value.length - 32, bytes, 0, 32);} else {System.arraycopy(value, 0, bytes, 32 - value.length, value.length);}return bytes;}
}private static ECPrivateKeyParameters encodePrivateKey(byte[] value) {BigInteger d = new BigInteger(1, value);return new ECPrivateKeyParameters(d, getECDomainParameters());
}private static byte[] encodeDERSignature(byte[] signature) {byte[] r = new byte[32];byte[] s = new byte[32];System.arraycopy(signature, 0, r, 0, 32);System.arraycopy(signature, 32, s, 0, 32);ASN1EncodableVector vector = new ASN1EncodableVector();vector.add(new ASN1Integer(new BigInteger(1, r)));vector.add(new ASN1Integer(new BigInteger(1, s)));try {return (new DERSequence(vector)).getEncoded();} catch (IOException var6) {throw new BusinessException("签名数据不正确", "TYSM224");}
}private static ECPublicKeyParameters encodePublicKey(byte[] value) {byte[] x = new byte[32];byte[] y = new byte[32];System.arraycopy(value, 1, x, 0, 32);System.arraycopy(value, 33, y, 0, 32);BigInteger iX = new BigInteger(1, x);BigInteger iY = new BigInteger(1, y);ECPoint ecQ = getSM2Curve().createPoint(iX, iY);return new ECPublicKeyParameters(ecQ, getECDomainParameters());
}private static ECCurve getSM2Curve() {ECParameterSpec spec = ECNamedCurveTable.getParameterSpec("sm2p256v1");return spec.getCurve();
}private static ECDomainParameters getECDomainParameters() {ECParameterSpec spec = ECNamedCurveTable.getParameterSpec("sm2p256v1");return new ECDomainParameters(spec.getCurve(), spec.getG(), spec.getN(), spec.getH(), spec.getSeed());
}/*** 通过SM3摘要器获取数据摘要** @return 摘要*/
private static byte[] CMBSM3Digest(byte[] msg) {byte[] bytes = new byte[32];SM3Digest digest = new SM3Digest();digest.update(msg, 0, msg.length);digest.doFinal(bytes, 0);digest.reset();return bytes;
}private static void initKeyBase64() {// 创建 sm2 对象SM2 sm2 = SmUtil.sm2();// 这里会自动生成对应的随机秘钥对 , 注意! 这里一定要强转,才能得到对应有效的秘钥信息byte[] privateKey = BCUtil.encodeECPrivateKey(sm2.getPrivateKey());// 这里公钥不压缩 公钥的第一个字节用于表示是否压缩 可以不要byte[] publicKey = ((BCECPublicKey) sm2.getPublicKey()).getQ().getEncoded(false);// 打印当前的公私秘钥System.out.println("SM2 公钥(HEX): " + HexUtil.encodeHexStr(publicKey));System.out.println("SM2 公钥长度(HEX): " + HexUtil.encodeHexStr(publicKey).length());System.out.println("SM2 公钥(BASE64): " + Base64.encodeBase64String(publicKey));System.out.println("SM2 公钥长度(BASE64): " + Base64.encodeBase64String(publicKey).length());System.out.println("SM2 私钥(HEX): " + HexUtil.encodeHexStr(privateKey));System.out.println("SM2 私钥公钥长度(HEX): " + HexUtil.encodeHexStr(privateKey).length());System.out.println("SM2 私钥(BASE64): " + Base64.encodeBase64String(privateKey));System.out.println("SM2 私钥长度(BASE64): " + Base64.encodeBase64String(privateKey).length());}public static void main(String[] args) {//initKeyBase64();Map<String, String> map = new HashMap<>(3);map.put("mobile", "18468242454");map.put("skuCode", "sku2021001");//TODO 后面替换为真实的核心企业IDmap.put("coreId", "sku2021001");String data = JSON.toJSONString(map);String publicSecret = "BMTxlXewbroQEvkgEg41bzUfYE5TVQiBpd4yrOeBQ9Ck3Kj0gHxvGaKnjc4ECwwJ7lIHYwNoCkh6JzxX/3sQ36A=";System.out.println("公钥字符长度:" + publicSecret.length());String privateSecret = "NgQBMpptzmgbnl2/yp1xBz7iafpBsyFEpz5kqhdpLSk=";System.out.println("私钥字符长度:" + privateSecret.length());System.out.println("加密前的字符:" + data);//用对方给的公钥加密,然后传给对方//result:加密得到的数据String result = cmbSM2Encrypt(publicSecret, data, "UTF-8");System.out.println("加密得到的字符:" + result);//dt:对方数据解密都得到的原文String olData = cmbSM2Decrypt(privateSecret, result, "UTF-8");System.out.println("解密后的字符:" + olData);String signData = cmbSM2Sign(privateSecret, data, "Y", "UTF-8");System.out.println("签名得到的字符:" + signData);Boolean y = cmbSM2Verify(publicSecret, data, signData, "Y", "UTF-8");System.out.println("签名验证结果:" + y);
}

}

SM2 国密加密加签操作工具相关推荐

  1. SM2国密算法加解密

    接口安全设计原则的一个点就是数据不能明文传输,除了https这个必须的请求外,接口数据加密也是一个重要的方式,下面介绍一下SM2国密算法加解密的使用方式. 这里我就针对目前前后端分离架构的方式来简单介 ...

  2. js 使用sm2 国密加密

    js 使用sm2 国密加密 由于项目中要对数据进行国密加密 注意: 同一个明文,加密后的密文都不同,解密的话要用私钥解密 js用sm2加密,首先要从后端获取公钥,用公钥加密 参考资料 crypto-j ...

  3. 技术分享 | 使用 mPaaS 配置 SM2 国密加密指南

    简介:随着移动智能终端的广泛应用,敏感信息极易被监控或盗取,给国家.企事业及个人带来极大政治.经济损失.金融和重要领域的各个企业正在逐步落实并完成国产密码改造工作.为解决客户侧因更换加密算法造成的种种 ...

  4. 【转】C#实现SM2国密加密

    本文主要讲解"国密加密算法"SM系列之SM2的C#实现方法,加密规则请详阅国密局发布的文档. 首先需第三方Nuget包:Portable.BouncyCastle (源码来自htt ...

  5. 国密SM4加解密SM2签名验签COM组件DLL

    提供给第三方软件,调用COM组件DLL方式进行实现,如delphi.PB等. 基于C#编写的COM组件DLL,可实现SM2签名验签,SM4加解密,100%适用于黑龙江省国家医保接口中进行应用. 功能包 ...

  6. Java国密加密SM2代码

    Java国密加密SM2代码 文章目录 Java国密加密SM2代码 前言 一.SM2是什么? 二.使用步骤 1.引入Maven库 2.密码工具类 3.安全工具类 4.SM2工具类 5.SM2工具实用类 ...

  7. SM2 国密算法被 Linux 内核社区接受

    喜欢就关注我们吧! 10 月 25 日,有开发者发文称,SM2 国密算法终于被 Linux 内核社区接受了.该作者表示,SM2 的补丁已经更新到了 v7 版本,这个版本的补丁最终被社区接受,目前已经合 ...

  8. 【转】C#实现SM3国密加密

    C#实现SM3国密加密 本文主要讲解"国密加密算法"SM系列之SM3的C#实现方法,加密规则请详阅国密局发布的文档. 首先需第三方Nuget包:Portable.BouncyCas ...

  9. C#实现SM2国密签名签验签和加密解密

    java版本已放出 对应的java版本 话不多说,上码. 依赖,BouncyCastle.Crypto.dll ,经测试,可与java版本的bcprov-jdk15on-1.62.jar互通. 在这里 ...

最新文章

  1. python 做词云 -jupyter跟随王树义教程学习
  2. 加密货币与智能合约的隐私 (四):私人和许可的分类帐
  3. java读取excel2010文件_java如何读写excel2010
  4. 智源-知乎联合发布大规模用户关系数据集,同步开启10万元竞赛
  5. 操作系统【连续式分配方式、隐式链接、显示链接、索引方式、混合索引、位示图、成组链接】
  6. ios上传音频文件到服务器,IOS开发:iPod的音乐库中的音频如何上传到服务器中...
  7. 解耦知识蒸馏,让Hinton在7年前提出的方法重回SOTA行列(CVPR 2022)
  8. 2017.9.5.1.语文
  9. 银行卡不销卡,对持卡人有没有什么影响?
  10. 华为中兴OLT-ONU上线单播组播配置常用命令及TestCenter测试组播和PPPoE
  11. 更改网页alert弹出框样式
  12. 工作流的大致开发流程
  13. pdf编辑器哪个好 怎么添加pdf文件水印
  14. cite、q、blockquote之间的区别
  15. Hans Petter Langtangen
  16. 并发与并行,线程与进程如何理解
  17. 使用 Python 和 Bitly 缩短您的 URL
  18. I06-python菜鸟教程查漏补缺
  19. 数字化工厂正在塑造制造业未来
  20. 在飞书群里设置机器人提醒 github 代码更新

热门文章

  1. 如何用计算机画双液液相图,实验二二组分固-液相图的绘制.ppt
  2. 计算机毕业设计ssm基于网络的景区旅游服务管理系统q57ng系统+程序+源码+lw+远程部署
  3. 什么是IoC 和 DI
  4. android自动开关流量,android开关gprs流量
  5. linux centos7保存防火墙设置,修改centos7防火墙设置,修改centos7防火墙
  6. 个人简记为css3,H5+css3春节贺卡之个人收获
  7. Android源码剖析之Framwork层后记篇(硬件消息传递、apk管理、输入法框架、编译过程)
  8. Android 密码正则表达式验证
  9. 智能手机游戏的六个残酷真相:对玩家一定要狠
  10. 校园文化建设计算机教室标语,学校标语:校园文化建设标语