首页 > 解决方案 > python 中 Crypto.Cipher.IDEA 模块中的错误

问题描述

你好呀,

i am writing a code for auto discovery of IP within the network and then 
data transfer using the socket programming in python. I have read the RSA 
and want to implement in the code. i go through to the link where i got 
the code implementation and the whole code for server and client.
Here is the link where the code is:

<https://riptutorial.com/python/example/27170/client-side-implementation>
<https://riptutorial.com/python/example/27169/server-side-implementation>

There are two links and the setup for PyCrypto is.

*PyCrypto (Download Link: https://pypi.python.org/pypi/pycrypto )

*PyCryptoPlus (Download Link: https://github.com/doegox/python-cryptoplus )

我在树莓派上尝试了它并安装了我上面写的所有基本模块,并使用如下命令行运行它:python3 server.py,但它给了我一些与模块相关的错误。

Crypto.Cipher.IDEA isn't available. You're probably using the Debian 
pycrypto version. Install the original pycrypto for IDEA.
Traceback (most recent call last):
File "serverRsa.py", line 10, in <module>
from CryptoPlus.Cipher import IDEA
File "/home/pi/.local/lib/python3.5/site- 
packages/CryptoPlus/Cipher/IDEA.py", line 4, in <module>
import Crypto.Cipher.IDEA
ImportError: No module named 'Crypto.Cipher.IDEA'

我尝试使用 pip install PyCrypto 并使用 pip3 相同。然后运行相同的代码但发生相同的错误。

Actually problem statement is to auto discover of all the nearby ip's 
using the python programming , where i run the code on Raspberry Pi and 
make it as a hotspot and other Pi boards act as client. Now when the 
server found the client or discover them then it register them using some 
key or encryption method.

我只需要使用 RSA 将一些消息传递给客户端的代码,但似乎代码有错误。请任何人解决此问题。

标签: pythoncryptographyrsa

解决方案


如果您真的需要 Python 2 中的 IDEA 密码,并且它很慢(比在 C 中实现的慢得多)对您来说是可以的,这里有一个:https ://pastebin.com/hTn5K3Tx 。像这样使用它:

cb = IDEA('2bd6459f82c5b300952c49104881ff48'.decode('hex'))
plaintext, ciphertext = 'f129a6601ef62a47'.decode('hex'), 'ea024714ad5c4d84'.decode('hex')
assert cb.encrypt(plaintext) == ciphertext
assert cb.decrypt(ciphertext) == plaintext

请注意,IDEA 的最后一项专利于 2012 年到期,现在 IDEA可供公众免费使用


推荐阅读