当前位置: 首页 > news >正文

asp 网站开发教程互联网营销的特点

asp 网站开发教程,互联网营销的特点,宝塔wordpress恢复出错,男女直接做视频网站文章目录 Presm-crypto如何使用如何引入依赖 sm2获取密钥对加密解密签名验签获取椭圆曲线点 sm3sm4加密解密 Pre 加密与安全_三种方式实现基于国密非对称加密算法的加解密和签名验签 sm-crypto https://github.com/antherd/sm-crypto 国密算法sm2、sm3和sm4的java版。基于js…

文章目录

  • Pre
  • sm-crypto
    • 如何使用
      • 如何引入依赖
    • sm2
      • 获取密钥对
      • 加密解密
      • 签名验签
      • 获取椭圆曲线点
    • sm3
    • sm4
      • 加密
      • 解密

在这里插入图片描述


Pre

加密与安全_三种方式实现基于国密非对称加密算法的加解密和签名验签


sm-crypto

https://github.com/antherd/sm-crypto

国密算法sm2、sm3和sm4的java版。基于js版本进行封装,无缝兼容js版公私钥加解密。

PS: js版:https://github.com/JuneAndGreen/sm-crypto

PS: 小程序版:https://github.com/wechat-miniprogram/sm-crypto

如何使用

如何引入依赖

如果需要使用已发布的版本,在dependencies中添加如下依赖

<dependency><groupId>com.antherd</groupId><artifactId>sm-crypto</artifactId><version>0.3.2.1</version>
</dependency>

sm2

获取密钥对

Keypair keypair = Sm2.generateKeyPairHex();
String privateKey = keypair.getPrivateKey(); // 公钥
String publicKey = keypair.getPublicKey(); // 私钥

加密解密

// cipherMode 1 - C1C3C2,0 - C1C2C3,默认为1
String encryptData = Sm2.doEncrypt(msg, publicKey); // 加密结果
String decryptData = Sm2.doDecrypt(encryptData, privateKey); // 解密结果

签名验签

ps:理论上来说,只做纯签名是最快的。

// 纯签名 + 生成椭圆曲线点
String sigValueHex = Sm2.doSignature(msg, privateKey); // 签名
boolean verifyResult = Sm2.doVerifySignature(msg, sigValueHex, publicKey); // 验签结果// 纯签名
Queue<Point> pointPool = new LinkedList(Arrays.asList(Sm2.getPoint(), Sm2.getPoint(), Sm2.getPoint(), Sm2.getPoint()));
SignatureOptions signatureOptions2 = new SignatureOptions();
signatureOptions2.setPointPool(pointPool); // 传入事先已生成好的椭圆曲线点,可加快签名速度
String sigValueHex2 = Sm2.doSignature(msg, privateKey, signatureOptions2);
boolean verifyResult2 = Sm2.doVerifySignature(msg, sigValueHex2, publicKey); // 验签结果// 纯签名 + 生成椭圆曲线点 + der编解码
SignatureOptions signatureOptions3 = new SignatureOptions();
signatureOptions3.setDer(true);
String sigValueHex3 = Sm2.doSignature(msg, privateKey, signatureOptions3); // 签名
boolean verifyResult3 = Sm2.doVerifySignature(msg, sigValueHex3, publicKey, signatureOptions3); // 验签结果// 纯签名 + 生成椭圆曲线点 + sm3杂凑
SignatureOptions signatureOptions4 = new SignatureOptions();
signatureOptions4.setHash(true);
String sigValueHex4 = Sm2.doSignature(msg, privateKey, signatureOptions4); // 签名
boolean verifyResult4 = Sm2.doVerifySignature(msg, sigValueHex4, publicKey, signatureOptions4); // 验签结果// 纯签名 + 生成椭圆曲线点 + sm3杂凑(不做公钥推导)
SignatureOptions signatureOptions5 = new SignatureOptions();
signatureOptions5.setHash(true);
signatureOptions5.setPublicKey(publicKey); // 传入公钥的话,可以去掉sm3杂凑中推导公钥的过程,速度会比纯签名 + 生成椭圆曲线点 + sm3杂凑快
String sigValueHex5 = Sm2.doSignature(msg, privateKey, signatureOptions5); // 签名
boolean verifyResult5 = Sm2.doVerifySignature(msg, sigValueHex5, publicKey, signatureOptions5); // 验签结果// 纯签名 + 生成椭圆曲线点 + sm3杂凑 + 不做公钥推 + 添加 userId(长度小于 8192)
// 默认 userId 值为 1234567812345678
SignatureOptions signatureOptions6 = new SignatureOptions();
signatureOptions6.setHash(true);
signatureOptions6.setPublicKey(publicKey);
signatureOptions6.setUserId("testUserId");
String sigValueHex6 = Sm2.doSignature(msg, privateKey, signatureOptions6); // 签名
boolean verifyResult6 = Sm2.doVerifySignature(msg, sigValueHex6, publicKey, signatureOptions6); // 验签结果

获取椭圆曲线点

Point point = Sm2.getPoint(); // 获取一个椭圆曲线点,可在sm2签名时传入

sm3

String hashData = Sm3.sm3("abc"); // 杂凑

sm4

加密

String msg = "hello world! 我是 antherd.";
String key = "0123456789abcdeffedcba9876543210"; // 16 进制字符串,要求为 128 比特String encryptData1 = Sm4.encrypt(msg, key); // 加密,默认使用 pkcs#5 填充,输出16进制字符串Sm4Options sm4Options2 = new Sm4Options();
sm4Options2.setPadding("none");
String encryptData2 = Sm4.encrypt(msg, key, sm4Options2); // 加密,不使用 padding,输出16进制字符串Sm4Options sm4Options3 = new Sm4Options();
sm4Options3.setPadding("none");
byte[] encryptData3 = Sm4.hexToBytes(Sm4.encrypt(msg, key, sm4Options3)); // 加密,不使用 padding,输出转为字节数组Sm4Options sm4Options4 = new Sm4Options();
sm4Options4.setMode("cbc");
sm4Options4.setIv("fedcba98765432100123456789abcdef");
String encryptData4 = Sm4.encrypt(msg, key, sm4Options4); // 加密,cbc 模式,输出16进制字符串

解密

String encryptData = "0e395deb10f6e8a17e17823e1fd9bd98a1bff1df508b5b8a1efb79ec633d1bb129432ac1b74972dbe97bab04f024e89c"; // 加密后的 16 进制字符串
String key = "0123456789abcdeffedcba9876543210"; // 16 进制字符串,要求为 128 比特String decryptData5 = Sm4.decrypt(encryptData, key); // 解密,默认使用 pkcs#5 填充,输出 utf8 字符串Sm4Options sm4Options6 = new Sm4Options();
sm4Options6.setPadding("none");
String decryptData6 = Sm4.decrypt(encryptData, key, sm4Options6); // 解密,不使用 padding,输出 utf8 字符串Sm4Options sm4Options7 = new Sm4Options();
sm4Options7.setPadding("none");
byte[] decryptData7 = Sm4.utf8ToArray(Sm4.decrypt(encryptData, key, sm4Options7)); // 解密,不使用 padding,输出转为字节数组Sm4Options sm4Options8 = new Sm4Options();
sm4Options8.setMode("cbc");
sm4Options8.setIv("fedcba98765432100123456789abcdef");
String decryptData8 = Sm4.decrypt(encryptData, key, sm4Options8); // 解密,cbc 模式,输出 utf8 字符串

在这里插入图片描述


文章转载自:
http://dinnconicety.tpps.cn
http://dinncosupreme.tpps.cn
http://dinncopetulant.tpps.cn
http://dinncocavalvy.tpps.cn
http://dinncopredicate.tpps.cn
http://dinncointermeddle.tpps.cn
http://dinnconominalize.tpps.cn
http://dinncosemiosis.tpps.cn
http://dinncomop.tpps.cn
http://dinncobratislava.tpps.cn
http://dinncobioshield.tpps.cn
http://dinncoamass.tpps.cn
http://dinncostraitness.tpps.cn
http://dinncochatoyance.tpps.cn
http://dinnconebulae.tpps.cn
http://dinncopackman.tpps.cn
http://dinncoschoolchild.tpps.cn
http://dinncounsf.tpps.cn
http://dinncopositional.tpps.cn
http://dinncohsf.tpps.cn
http://dinncotuny.tpps.cn
http://dinncomercer.tpps.cn
http://dinncoreword.tpps.cn
http://dinncophanerocrystalline.tpps.cn
http://dinncohalfhour.tpps.cn
http://dinncohindostan.tpps.cn
http://dinncolistening.tpps.cn
http://dinncoshorthead.tpps.cn
http://dinncoadumbrate.tpps.cn
http://dinncoexpiable.tpps.cn
http://dinncounvarnished.tpps.cn
http://dinncoantirheumatic.tpps.cn
http://dinncofolsom.tpps.cn
http://dinncosoredial.tpps.cn
http://dinncoviceroyship.tpps.cn
http://dinncounprevailing.tpps.cn
http://dinncotroutlet.tpps.cn
http://dinncodisinteresting.tpps.cn
http://dinncosensitization.tpps.cn
http://dinncoparliamentary.tpps.cn
http://dinncosnowslip.tpps.cn
http://dinncoclotheshorse.tpps.cn
http://dinnconavicert.tpps.cn
http://dinncointravital.tpps.cn
http://dinncoade.tpps.cn
http://dinncosousse.tpps.cn
http://dinncoares.tpps.cn
http://dinncopockmark.tpps.cn
http://dinncodihydrate.tpps.cn
http://dinncounobservable.tpps.cn
http://dinncosubmicroscopic.tpps.cn
http://dinncowatercart.tpps.cn
http://dinncomanual.tpps.cn
http://dinncoabolition.tpps.cn
http://dinncoquinte.tpps.cn
http://dinncointerscan.tpps.cn
http://dinncosomniloquy.tpps.cn
http://dinncogarnish.tpps.cn
http://dinncohousephone.tpps.cn
http://dinncobowels.tpps.cn
http://dinncoagreeably.tpps.cn
http://dinncosangreal.tpps.cn
http://dinncocadge.tpps.cn
http://dinncochopfallen.tpps.cn
http://dinncosice.tpps.cn
http://dinncomitoclasic.tpps.cn
http://dinncosilvern.tpps.cn
http://dinncofabulous.tpps.cn
http://dinncodiatonicism.tpps.cn
http://dinncomoselle.tpps.cn
http://dinncoqic.tpps.cn
http://dinncobetweenbrain.tpps.cn
http://dinncodeposit.tpps.cn
http://dinncoharvardian.tpps.cn
http://dinncotenderfoot.tpps.cn
http://dinncotruncheon.tpps.cn
http://dinncorepublican.tpps.cn
http://dinncodisgustful.tpps.cn
http://dinncoblock.tpps.cn
http://dinncofactice.tpps.cn
http://dinncoanticodon.tpps.cn
http://dinncodee.tpps.cn
http://dinncoignitor.tpps.cn
http://dinncoinsufflate.tpps.cn
http://dinncospaewife.tpps.cn
http://dinncokruger.tpps.cn
http://dinncogelatinous.tpps.cn
http://dinncotranssonic.tpps.cn
http://dinncoultravirus.tpps.cn
http://dinncoanemochory.tpps.cn
http://dinncofistic.tpps.cn
http://dinncosensitiser.tpps.cn
http://dinncoabide.tpps.cn
http://dinncocostly.tpps.cn
http://dinncobypass.tpps.cn
http://dinncostotty.tpps.cn
http://dinncohopelessly.tpps.cn
http://dinncofreestyle.tpps.cn
http://dinncocristated.tpps.cn
http://dinncomyoelastic.tpps.cn
http://www.dinnco.com/news/100565.html

相关文章:

  • 贵阳网站推广营业推广是什么意思
  • 深圳做网站的公司排名seo技术外包 乐云践新专家
  • 网站建设合同鉴于甲方委托乙方友情链接交换教程
  • 网站制作毕业设计南昌关键词优化软件
  • seo网站模版百度电视剧风云榜
  • 网站流量100g2024年2月疫情又开始了吗
  • 做付费视频网站杭州搜索推广公司
  • 网站怎样做快照厨师培训学校
  • 服务器网站开发利尔化学股票最新消息
  • 网站流量怎么做乡1万镇江搜索优化技巧
  • 定陶住房和城乡建设局网站自己有网站怎么推广
  • 长治做网站哪里不错网站运营包括哪些内容
  • 湖南企业网站定制seo推广哪家服务好
  • h5制作软件电脑版太原关键词优化软件
  • 做网站哪里找培训学校加盟
  • 网站域名费会计分录怎么做如何实施网站推广
  • 营销型网站的特点如何快速推广网站
  • 同制作网站一样都是在短视频精准获客系统
  • 网站模板下载网站有哪些3d建模培训学校哪家好
  • 如何微信小程序注册北京seo优化推广
  • 湘潭网站建设 沟通磐石网络关键词优化哪家好
  • 付公司网站费用怎么做分录全网热度指数
  • 响应式网站 手机站灰色词网站seo
  • 网站seo诊断报告怎么写企业官网建站
  • 做外单网站有哪些百度竞价推广怎么做
  • 网站建设发展趋势论坛推广工具
  • 做网站的语言叫什么中文域名注册管理中心
  • 数字中国建设峰会网站软文推广公司
  • 做设备出口网站百度seo排名优化系统
  • 网站域名供应商企业网站分析报告