Я пытаюсь перевести объект с открытым ключом в форму pickle из client.py, затем передать его через поток сокетов, а затем снова открыть его обратно в server.py.
Я получаю ImportError: Нет модуля с именем DS на стороне сервера, когда я пытаюсь открыть поток через publicKey = pickle.loads (команда [4]). Вот полная ошибка:
(iCrypto.PublicKey.DSA
Traceback (most recent call last):
File "server.py", line 148, in <module>
main()
File "server.py", line 56, in main
publicKey = pickle.loads(command[4])
File "/usr/lib/python2.7/pickle.py", line 1388, in loads
return Unpickler(file).load()
File "/usr/lib/python2.7/pickle.py", line 864, in load
dispatch[key](self)
File "/usr/lib/python2.7/pickle.py", line 1075, in load_inst
klass = self.find_class(module, name)
File "/usr/lib/python2.7/pickle.py", line 1130, in find_class
__import__(module)
ImportError: No module named DS
Ключевой объект это:
import Crypto.PublicKey.RSA as RSA
import Crypto.PublicKey.DSA as DSA
import Crypto.Util.number as CUN
from Crypto.Cipher import PKCS1_OAEP
import os
# Generates a new set of keys for the session
def GeneratesKeys():
return RSA.generate(1024, os.urandom)
И вот фактический код:
server.py
data = s.recv(1024)
if data:
command = data.split()
if command[0] == "message":
print command[1] + " & " + command[2] + " have been invited!"
alg = command[3]
print "test"
print command[4]
import pickle
publicKey = pickle.loads(command[4])
print publicKey
# Encrypt symmetric key w/ user's public key
pvtPubKeys.EncryptMessages(symmetricKey, publicKey, alg)
client.py
import pickle
pubKey = pickle.dumps(account.publicKey)
print account.publicKey
# Invited user sends other info to server
s.sendall("message" + " " + myUsername + " " + theirUsername + " " + choice + " " + pubKey)
Можете ли вы помочь мне здесь?
Спасибо.