Do we have any library or any mechanism where we can use true 7 byte key for DES instead of 8 byte key. I need it for keys analysis in DES and 8 byte key requirement for associated library is creating problem in getting actual keys analysis.
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
You need to split up your key into eight 7 bit pieces, and put these 7 bits into a byte each. The parity is in the least significant bit on most platforms, so the 7 bits need to go into the most significant bits. Of course, as the key is probably in bytes, you need to shift and combine the values in the bytes to retrieve the 7 bits.
It's possible the library does not require the parity bits to be set. In that case you don't need to calculate the parity. Otherwise you simply create the parity once you've got the 8 bytes.
Following code is in Java (which makes it a bit awkward because Java bytes are signed and most calculations assume integers).
Here, I edited existing pyDes library just by adding a new function to convert a 7 byte key into 64 bits required by the code. But I am not sure if the code implements DES in true sense