(Mar-10-2021, 07:18 PM)buran Wrote: You have problem sending the public key from the server. You send a str representation of PublicKey instance. Then on client side after decoding you just take first 2 char from that str and try to use them when encrypt you password message
not tested, but try
in server replace line 56msg = f'{pkey}'
withmsg = pkey.hex()
in client replace line 13serverkey = s.recv(1024).decode()
withserverkey = PublicKey.from_hex(s.recv(1024).decode())
note, you need to importPublicKey
before use it
and then line 15 will become msg = f'PSWD{RSA.Message.from_hex(new_pass).encrypt(serverkey)}'
Also, not sure you want to useMessage.from_hex()
to create message for the new password.
ALSO, Same apply when sending client public key to server - try to make same changes on your own, otherwise you will get the same error when server try to use client public key.
now i just get this:
Error:Traceback (most recent call last):
File "C:\Users\####\PycharmProjects\pythonProject\main.py", line 15, in <module>
msg = f'PSWD{RSA.Message.from_hex(new_pass).encrypt(serverkey)}'
File "C:\Python39\lib\site-packages\cryptotools\RSA\rsa.py", line 25, in encrypt
e, n = key
TypeError: cannot unpack non-iterable PublicKey object