3
使用示例代码使用RSA加密邮件,但出现以下错误。使用RSA加密邮件的错误python
Traceback (most recent call last):
File "E:/PythonProjects/skypy/skypy/codebase/utils/crypto.py", line 32, in <module>
print(RSAPubKey.encrypt("Hello.", 32))
File "E:\Programs\Python3.4\lib\site-packages\Crypto\PublicKey\RSA.py", line 150, in encrypt
return pubkey.pubkey.encrypt(self, plaintext, K)
File "E:\Programs\Python3.4\lib\site-packages\Crypto\PublicKey\pubkey.py", line 75, in encrypt
ciphertext=self._encrypt(plaintext, K)
File "E:\Programs\Python3.4\lib\site-packages\Crypto\PublicKey\RSA.py", line 224, in _encrypt
return (self.key._encrypt(c),)
File "E:\Programs\Python3.4\lib\site-packages\Crypto\PublicKey\_slowmath.py", line 65, in _encrypt
return pow(m, self.e, self.n)
TypeError: unsupported operand type(s) for pow(): 'str', 'int', 'int'
下面是示例代码
from Crypto.PublicKey import RSA
from Crypto.Util import randpool
blah = randpool.RandomPool()
RSAKey = RSA.generate(1024, blah.get_bytes)
RSAPubKey = RSAKey.publickey()
print(RSAPubKey.encrypt("Hello.", 32))
OS使用的Windows是,什么可能是由于这个问题?