Git Product home page Git Product logo

Comments (5)

JuneAndGreen avatar JuneAndGreen commented on July 17, 2024

128 / 8 = 16(字节)

16 进制串中,0xff = 11111111 = 8位 = 1字节 = 字符串长度2

from sm-crypto.

YaroED avatar YaroED commented on July 17, 2024

后端的包是传16位,我传16位的utf8串,加密会报错。这个是一定要32位的16进制串吗?

from sm-crypto.

YaroED avatar YaroED commented on July 17, 2024

@JuneAndGreen

from sm-crypto.

changhr2013 avatar changhr2013 commented on July 17, 2024

密钥一般是随机的比特序列,一般随机性比较好的密钥,用字符串是无法表示的,所以一般密钥都会使用 16 进制编码进行表示。
你后端传的 16 位字符串,那你将 16 位字符串做 Hex 编码后变成 32 位的 16 进制字符串传入即可。

from sm-crypto.

JuneAndGreen avatar JuneAndGreen commented on July 17, 2024

后端的包是传16位,我传16位的utf8串,加密会报错。这个是一定要32位的16进制串吗?

image

是的,你需要手动转成对应的hex串,也可以转成最原始的字节数组

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.