Python如何用模+指数编码RSA

2024-05-14 18:55:13 发布

您现在位置:Python中文网/ 问答频道 /正文

你好,我需要编码文本与RSA使用模数和指数+输入

我已经试过了,但是有错误

            rsa_modulus = data['publickey_mod']
            rsa_exponent = data['publickey_exp']
            rsa_timestamp = data['timestamp']
            rsa_publickey = rsa.PublicKey(rsa_modulus, rsa_exponent)
            encrypted = rsa.encrypt(password,rsa_publickey)
            print(encrypted)

AttributeError:“str”对象没有“bit\u length”属性


Tags: 文本mod编码data错误指数rsatimestamp
2条回答

希望您这样做只是为了演示,而不是为了实际的安全关键型应用程序。因为以这种方式使用RSA而不使用任何随机填充是不安全的。你知道吗

How do you encrypt a password by using the RSA Algorithm?

尝试对password进行编码:

encrypted = rsa.encrypt(password.encode('utf8'), rsa_publickey)

rsa.Encrypt接受byte对象

相关问题 更多 >

    热门问题