首页 > 解决方案 > Python如何使用模数+指数使用RSA进行编码

问题描述

您好,我需要使用模数和指数 + 输入使用 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_length”

标签: pythonpython-3.xrsapython-cryptography

解决方案


希望您这样做是为了演示,而不是针对实际的安全关键应用程序。因为以这种方式仅使用 RSA 而没有任何随机填充是不安全的。

请参阅如何使用 RSA 算法加密密码?


推荐阅读