Code Monkey home page Code Monkey logo

Comments (4)

zcong2333 avatar zcong2333 commented on June 26, 2024

我目前查到sm2加密结果是C1X+C1Y+C3+C2,其中C1X,C1Y说是32字节,但也可能少于32字节的情况,位数少了估计是这个问题,服务端解密也不知道怎么改,java一般是基于bouncycastle这个库,也不知道有没有新的可以兼容。基于openssl的话,https://xie.infoq.cn/article/9685264098848c3024593c629可以看看这个,升级一下版本,我也还没验证

from sm-crypto.

changhr2013 avatar changhr2013 commented on June 26, 2024

@xiaopihaipanwei 我运行了 1 万次加密,复现不了位数不对的情况,如果有能复现的代码麻烦贴一下看看。

from sm-crypto.

xiaopihaipanwei avatar xiaopihaipanwei commented on June 26, 2024

@changhr2013

前端代码

const sm2 = require("sm-crypto").sm2;

const bizData = sm2.doEncrypt("12345abc", this.publicKey1, 1);

正常密文(210)

04604f47a1393186d19047844f8efef837bea2339787b27daf58d10154dda3f1793a0b12906f9e62e189a0dc322d8d7ad2b8d2838cc14fd184135755c4b1f69ab401b31b0645489f8909823ad6cdd1b38aef97ad5c5ee17794f8d8a844509e056717be25653427d00f

无法解密密文(208)

044fafb9e39172c9268f4cf37e24dc47a0be6f1ebf17295f479dd8afd477adeeffd65f97de271997815a4bd5d656991104a12638e727ff10a9c7a51d3c375b6178203b096f98f058203af720fa1e7844d475a1dee433ee14b5eab508939842290a18e239aa5886bb

from sm-crypto.

xiaopihaipanwei avatar xiaopihaipanwei commented on June 26, 2024

@changhr2013 不好意思 刚刚和前端比对了一下,发现是有概率出现加密原文开头是04的情况,所以后端判断没有加上04导致无法解密. 麻烦大佬了

from sm-crypto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.