Esempio n. 1
0
 /**
  * @param k another key
  * @return a new Key which is the result of this key XOR the given key
  */
 public Key xor(Key k) {
   if (k.getByteLength() != getByteLength())
     throw new IllegalArgumentException("incompatable key for xor");
   byte[] b = new byte[getByteLength()];
   for (int i = 0; i < b.length; ++i) {
     b[i] = (byte) (getBytes()[i] ^ k.getBytes()[i]);
   }
   return new Key(b);
 }
Esempio n. 2
0
 private int getKBucketIndex(Key key) {
   return key.xor(localNode.getKey()).getFirstSetBitIndex();
 }
Esempio n. 3
0
 @Override
 public int compareTo(Key arg0) {
   return toString().compareTo(arg0.toString());
 }