Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?
share|improve this question
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? – Paŭlo Ebermann Apr 16 '14 at 20:37
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. – MHS Apr 16 '14 at 20:57

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.

share|improve this answer
Since we're talking about implementation, it should be noted that XOR is embarrassingly parallel, if the message size merits it. – rath Apr 17 '14 at 13:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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