我有一个公钥可以使用,我需要用我得到的RSA公钥对一些文本进行加密
这是我目前掌握的代码:
import rsa
fKey = open('key','r')
publicKey = fKey.read()
cipher = rsa.encrypt('Test', publicKey)
print(cipher)
使用此代码,我不断收到以下错误:
Traceback (most recent call last):
File "login.py", line 30, in <module>
cipher = rsa.encrypt('Test', publicKey)
File "/home/vagrant/.local/lib/python3.8/site-packages/rsa/pkcs1.py", line 169, in encrypt
keylength = common.byte_size(pub_key.n)
AttributeError: 'str' object has no attribute 'n'
有人能给我指一下正确的方向吗
注意:我必须使用该公钥文件
我就是这样解决的
相关问题 更多 >
编程相关推荐