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 56
in client replace line 13
note, you need to import
and then line 15 will become msg = f'PSWD{RSA.Message.from_hex(new_pass).encrypt(serverkey)}'
Also, not sure you want to use
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.
not tested, but try
in server replace line 56
msg = f'{pkey}'
with msg = pkey.hex()
in client replace line 13
serverkey = s.recv(1024).decode()
with serverkey = PublicKey.from_hex(s.recv(1024).decode())
note, you need to import
PublicKey
before use itand then line 15 will become msg = f'PSWD{RSA.Message.from_hex(new_pass).encrypt(serverkey)}'
Also, not sure you want to use
Message.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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs