title: Bit manipulation of chars in Java or C?
body: <p>I am a student trying to implement the DES algorithm.
  I have a choice of 2 languages: C &amp; Java.
  I did understand the algorithm, but am stuck at the very beginning as to manipulation of the key.</p>
  
  <p>Here's the problem.
  In DES, we have a 64-bit key (8 chars in C and 4 in Java, although I can cast the char to byte to get only the ASCII part), of which every 8th bit is a parity bit and needs to be stripped to make it a 56-bit key and do further processing. I have thought about this for long, but cannot find a way to strip every 8th bit and store the result in another char array (in Java as well as C).
  I tried using the <code>java.util.BitSet class</code>, but got confused.</p>
  
  <p>Any suggestions as to how can I remove every 8th bit and concat adjacent bytes(Java) or chars(C) to get the 56 bit key?</p>
  
  <p>I am aware of the bit operations and shifting, but for the specific example:<br>
  Suppose I have an 16 bit key: <code>1100 1001 1101 1000</code>.<br>
  I need to remove the 8th and 16th bit, making the key: <code>1100 100 1101 100</code>.</p>
  
  <p>If I declare 2 bytes, how do I truncate the 8th bit and append the 9th bit to it, making the first byte: <code>1100 1001</code></p>
  
  <p>So, what I need help with is how do I, replace 8th bit with 9th bit, replace 16th bit with 17th bit and so on to derive a 56-bit key from 64-bit key?</p>
  
  <p>If someone can explain it to me, I might probably be able to implement it regardless of language.</p>