Search code examples
javabouncycastledesencryption-symmetric

Why does generateKey method from DES algorithm multiply the key by 8?


I am in need of some explanations on the corresponding line, which I do not understand:

KeyGenerationParameters kgp = new KeyGenerationParameters(sr,(DESParameters.DES_KEY_LENGTH) * 8);

Would it stop working, if I had, for instance, the number 6 instead of 8?


Solution

  • It is multiplied by 8 because it is in bytes otherwise. The code wants bits.