title: BitShifting with BigIntegers in Java
body: <p>I am implementing DES Encryption in Java with use of BigIntegers.</p>
  
  <p>I am left shifting binary keys with Java BigIntegers by doing the BigInteger.leftShift(int n) method. Key of N (Kn) is dependent on the result of the shift of Kn-1.  The problem I am getting is that I am printing out the results after each key is generated and the shifting is not the expected out put.  The key is split in 2 Cn and Dn (left and right respectively).</p>
  
  <p>I am specifically attempting this:
  "To do a left shift, move each bit one place to the left, except for the first bit, which is cycled to the end of the block. "</p>
  
  <p>It seems to tack on O's on the end depending on the shift. Not sure how to go about correcting this.</p>
  
  <p>Results:</p>
  
  <p>c0: 11110101010100110011000011110</p>
  
  <p>d0: 11110001111001100110101010100</p>
  
  <p>c1: 111101010101001100110000111100</p>
  
  <p>d1: 111100011110011001101010101000</p>
  
  <p>c2: 11110101010100110011000011110000</p>
  
  <p>d2: 11110001111001100110101010100000</p>
  
  <p>c3: 1111010101010011001100001111000000</p>
  
  <p>d3: 1111000111100110011010101010000000</p>
  
  <p>c4: 111101010101001100110000111100000000</p>
  
  <p>d4: 111100011110011001101010101000000000</p>
  
  <p>c5: 11110101010100110011000011110000000000</p>
  
  <p>d5: 11110001111001100110101010100000000000</p>
  
  <p>c6: 1111010101010011001100001111000000000000</p>
  
  <p>d6: 1111000111100110011010101010000000000000</p>
  
  <p>c7: 111101010101001100110000111100000000000000</p>
  
  <p>d7: 111100011110011001101010101000000000000000</p>
  
  <p>c8: 1111010101010011001100001111000000000000000</p>
  
  <p>d8: 1111000111100110011010101010000000000000000</p>
  
  <p>c9: 111101010101001100110000111100000000000000000</p>
  
  <p>d9: 111100011110011001101010101000000000000000000</p>
  
  <p>c10:    11110101010100110011000011110000000000000000000</p>
  
  <p>d10:    11110001111001100110101010100000000000000000000</p>
  
  <p>c11:    1111010101010011001100001111000000000000000000000</p>
  
  <p>d11:    1111000111100110011010101010000000000000000000000</p>
  
  <p>c12:    111101010101001100110000111100000000000000000000000</p>
  
  <p>d12:    111100011110011001101010101000000000000000000000000</p>
  
  <p>c13:    11110101010100110011000011110000000000000000000000000</p>
  
  <p>d13:    11110001111001100110101010100000000000000000000000000</p>
  
  <p>c14:    1111010101010011001100001111000000000000000000000000000</p>
  
  <p>d14:    1111000111100110011010101010000000000000000000000000000</p>
  
  <p>c15:    11110101010100110011000011110000000000000000000000000000</p>
  
  <p>d15:    11110001111001100110101010100000000000000000000000000000</p>