Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I did a quick scan of the code. All messages are sent after being encrypted, so the total data you send is a multiple of 16, plus 1 for the command. So far, so good.</p> <p>On the decrypting side, you strip off the command, which leaves you with a message that is a multiple of 16 again. However, you are calling <code>msg.strip()</code> before you call <code>decrypt_my_message</code>. It is possible that the call to <code>strip</code> corrupts your encrypted data by removing bytes from the beginning or the end.</p> <p>I will examine the code further, and edit this answer if I find anything else.</p> <hr> <p>EDIT:</p> <p>You are using space character for padding, and I suppose you meant to remove the padding using the <code>strip</code> call. You should change <code>decrypt_my_message(msg.strip())</code> to <code>decrypt_my_message(msg).strip()</code>.</p> <hr> <p>You are using TCP to send the data, so your protocol is bound to give you headaches in the long term. I always send the length of the payload in my messages with this sort of custom protocol, so the receiving end can determine if it received the message block correctly. For example, you could use: <code>CMD|LEN(2)|PAYLOAD(LEN)</code> as your data frame. It means, one byte for command, two more bytes to tell the server how many bytes to expect, and <code>LEN</code> bytes of actual message. This way, your <code>recv</code> call can loop until it reads the correct amount. And more importantly, it will not attempt to read the next packet when/if they are sent back-to-back.</p> <p>Alternatively, if your packets are small enough, you could go for UDP. It opens up another can of worms, but you know that the <code>recv</code> will only receive a single packet with UDP.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload