Comments (4)
我目前查到sm2加密结果是C1X+C1Y+C3+C2,其中C1X,C1Y说是32字节,但也可能少于32字节的情况,位数少了估计是这个问题,服务端解密也不知道怎么改,java一般是基于bouncycastle这个库,也不知道有没有新的可以兼容。基于openssl的话,https://xie.infoq.cn/article/9685264098848c3024593c629可以看看这个,升级一下版本,我也还没验证
from sm-crypto.
@xiaopihaipanwei 我运行了 1 万次加密,复现不了位数不对的情况,如果有能复现的代码麻烦贴一下看看。
from sm-crypto.
前端代码
const sm2 = require("sm-crypto").sm2;
const bizData = sm2.doEncrypt("12345abc", this.publicKey1, 1);
正常密文(210)
04604f47a1393186d19047844f8efef837bea2339787b27daf58d10154dda3f1793a0b12906f9e62e189a0dc322d8d7ad2b8d2838cc14fd184135755c4b1f69ab401b31b0645489f8909823ad6cdd1b38aef97ad5c5ee17794f8d8a844509e056717be25653427d00f
无法解密密文(208)
044fafb9e39172c9268f4cf37e24dc47a0be6f1ebf17295f479dd8afd477adeeffd65f97de271997815a4bd5d656991104a12638e727ff10a9c7a51d3c375b6178203b096f98f058203af720fa1e7844d475a1dee433ee14b5eab508939842290a18e239aa5886bb
from sm-crypto.
@changhr2013 不好意思 刚刚和前端比对了一下,发现是有概率出现加密原文开头是04的情况,所以后端判断没有加上04导致无法解密. 麻烦大佬了
from sm-crypto.
Related Issues (20)
- 提供一个高性能的Java版,采用了BC库
- 一些其他的版本实现,方便取用 HOT 2
- sm4.encrypt的key要求是128比特,可是demo那里的字符是32位。 HOT 5
- sm4.encrypt的key要求是128比特,可是demo那里的字符是32位。
- uniapp 提示未定义 HOT 4
- sm4密钥 HOT 7
- hi, 这个工具又从证书获取公钥或私钥的方法吗? HOT 7
- 什么时候支持ts呀? HOT 1
- 请问能支持国密csr生成吗? HOT 4
- 使用前端进行签名后,使用golang后端进行验签,发现验证失败。 HOT 1
- 鸿蒙OS SM2签名中文,后端验签失败,去掉中文就可以验签通过
- sm3 hmac 算出来的结果和 crypto 算出来的结果不一样
- iv is invalid HOT 3
- 生成的密钥对结构和java的不一样 HOT 2
- sm4加密文件后无法解密 HOT 7
- sm4 加密报错
- 在使用代码混淆后,无法加解密 HOT 1
- vue项目,计算视频文件SM3,大一点的就崩溃 HOT 5
- SM2解密 后台采用hutool,密文加了04,但是还是偶发解密不了,报错InvalidCipherTextException: invalid cipher text HOT 1
- IE 出现兼容问题,建议修改 packjson 的main的路径 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sm-crypto.