Git Product home page Git Product logo

Comments (6)

CherryRum avatar CherryRum commented on July 20, 2024

首先,不太理解为啥您要使用,不同的构造,
您的问题在于,有没有一种可能sm2加密是包含盐值计算的,所以你每次的加密字符串都不一样的。

from hutool.

xdewx avatar xdewx commented on July 20, 2024

首先,不太理解为啥您要使用,不同的构造, 您的问题在于,有没有一种可能sm2加密是包含盐值计算的,所以你每次的加密字符串都不一样的。

你说的对,我查到非对称加密算法一般都有随机数。但是我想实现对输入的每次加密都相同,有样例可参考吗

from hutool.

CherryRum avatar CherryRum commented on July 20, 2024

1.你这需求,我怎么理解都是对称加密
2.可以非对称加密,那就找一个可以固定填充的(padding),或者删除填充,但是会降低性能

# e, n代表公钥
e = xxxx
n = xxxxxxxxxxx

m = b'123456'
m = int.from_bytes(m, 'big')
c = pow(m, e, n)
#不带任何填充,随机数
c = c.to_bytes((c.bit_length() + 7) // 8, 'big')
# 密文c发送给服务器
send(c)

所以这个RSA属于歪门邪道的实现,可能需要你自己实现一个

from hutool.

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.