I did work on the encryption algorithm and the decryption using the XOR method noticed that when more the key length, the less time spent on encryption and decryption.

I have two questions in particular:

  1. Why the greater the key length less time?
  2. in encryption algorithms using the XOR. Is the key should be a certain length or not?
  • $\begingroup$ Could you elaborate a bit what your "encryption algorithm using the XOR method" is exactly? For an one-time pad, the key length should be as much as the message length, so I suppose you are using something with repeated key? $\endgroup$ Apr 16, 2014 at 20:37
  • $\begingroup$ Ok for example I use k1 has length 256 bit with message has 1024 bit then I divide message for four parts each part has 256 bit. then I encrypt each chunk by use key1. $\endgroup$
    – MHS
    Apr 16, 2014 at 20:57

1 Answer 1


For simple XOR-based encryption algorithms such as OTP, the key size must be the same as the message size. If you choose a smaller key and try to divide the message into chunks, you would not have a perfectly secure scheme anymore.

Now, since you tagged java, I'm assuming that this increase in time for smaller key sizes is due to the code trying to divide the message into chunks. In that case, this doesn't have much to do with the algorithm, but rather with how you are writing your code.

  • $\begingroup$ Since we're talking about implementation, it should be noted that XOR is embarrassingly parallel, if the message size merits it. $\endgroup$
    – rath
    Apr 17, 2014 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.