Code Monkey home page Code Monkey logo

Comments (6)

yixianluo avatar yixianluo commented on June 2, 2024

碰到类似问题,sm4是按16的倍数进行加密,有其他js实现跨越参考吗

from sm-crypto.

mu-yu avatar mu-yu commented on June 2, 2024

@yixianluo 原始字符串可以是任意长度的,只不过要进行 padding/unpadding,这个库没有实现这一步而已。

还有这个可以参考下:
sm-series-crypto

from sm-crypto.

fancyboynet avatar fancyboynet commented on June 2, 2024

不知道作者有没有计划修复这个问题

from sm-crypto.

gy0801151351 avatar gy0801151351 commented on June 2, 2024

SM4对于key和iv的要求都是128位, 但是找了好多前端js的算法, 都把128位理解错了( 单纯的把128位换算成字符串的长度限制为16了, 其实是需要按字节位数换算. 比如base64格式和hex格式的key和iv, 需要先转换格式). 导致前端的sm4加密无法使用后端语言解密.

from sm-crypto.

mu-yu avatar mu-yu commented on June 2, 2024

SM4对于key和iv的要求都是128位, 但是找了好多前端js的算法, 都把128位理解错了( 单纯的把128位换算成字符串的长度限制为16了, 其实是需要按字节位数换算. 比如base64格式和hex格式的key和iv, 需要先转换格式). 导致前端的sm4加密无法使用后端语言解密.

无法解密可能是加密模式不同导致的,同样的 sm4,还分 cbc 和 ecb 等…

from sm-crypto.

JuneAndGreen avatar JuneAndGreen commented on June 2, 2024

key 要求 128 比特,加解密字符串在 0.2.0 版本支持了字符串输入和填充,详情可参考 README 或 testcase。

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.