Exemplo 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);
 }
Exemplo n.º 2
0
 private int getKBucketIndex(Key key) {
   return key.xor(localNode.getKey()).getFirstSetBitIndex();
 }
Exemplo n.º 3
0
 @Override
 public int compareTo(Key arg0) {
   return toString().compareTo(arg0.toString());
 }