code: public static boolean isParityAdjusted(byte[] key, int offset)
          throws InvalidKeyException {
              if (key == null) {
                  throw new InvalidKeyException("null key");
              }
              if (key.length - offset < DES_KEY_LEN) {
                  throw new InvalidKeyException("Wrong key size");
              }
  
              for (int i = 0; i < DES_KEY_LEN; i++) {
                  int k = Integer.bitCount(key[offset++] & 0xff);
                  if ((k & 1) == 0) {
                      return false;
                  }
              }
  
              return true;
      }
docs: Checks if the given DES key material, starting at <code>offset</code>
  inclusive, is parity-adjusted.
  
  @param key the buffer with the DES key material.
  @param offset the offset in <code>key</code>, where the DES key
  material starts.
  
  @return true if the given DES key material is parity-adjusted, false
  otherwise.
  
  @exception InvalidKeyException if the given key material is
  <code>null</code>, or starting at <code>offset</code> inclusive, is
  shorter than 8 bytes.