DES key parity bit calculator

I was doing some reverse engineering and I could not find any tool which expands a 56 bit DES key into a 64 bit key with the parity bit included. Expanding the key is a pretty laborious process involving hex to bin conversions and plenty of manual counting. To add on, some online tools truncate leading 0s when converting hex to bin, causing me to double check and triple check my workings before realising that the tool was the problem. Other tools use parseInt to do the conversion, which is unable to process 56 bit numbers.

I will not elaborate too much into the process as there is enough material online covering the algorithm. Basically, the effective key size of DES is 56 bits. The 64 bit key contains 8 parity bits which can be be calculated from the 56 bit key. The steps are as follows:

  1. Convert 56 bit key into binary form
  2. Separate bits into groups of 7
  3. If there are odd number of 1s in each group, add a 0 bit at the end, else add a 1
  4. Each group should now have 8 bits, convert to hex to get 64 bit key.

The entire computation is done in javascript and no information about the key is sent back to my server. Feel free to encrypt or decrypt your deepest darkest secrets. For the paranoid, you can even disconnect from the internet after the page has loaded.