java.math.BigInteger.xor()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(215)

本文整理了Java中java.math.BigInteger.xor()方法的一些代码示例,展示了BigInteger.xor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BigInteger.xor()方法的具体详情如下:
包路径:java.math.BigInteger
类名称:BigInteger
方法名:xor

BigInteger.xor介绍

[英]Returns a BigInteger whose value is this ^ value.

Implementation Note: Usage of this method is not recommended as the current implementation is not efficient.
[中]返回一个BigInteger,其值为^value。
实施说明:不建议使用此方法,因为当前的实施效率不高。

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

@VisibleForTesting
protected String encryptPasswordInternal( String password ) {
 if ( password == null ) {
  return "";
 }
 if ( password.length() == 0 ) {
  return "";
 }
 BigInteger bi_passwd = new BigInteger( password.getBytes() );
 BigInteger bi_r0 = new BigInteger( getSeed() );
 BigInteger bi_r1 = bi_r0.xor( bi_passwd );
 return bi_r1.toString( RADIX );
}

代码示例来源:origin: pentaho/pentaho-kettle

@VisibleForTesting
protected String decryptPasswordInternal( String encrypted ) {
 if ( encrypted == null ) {
  return "";
 }
 if ( encrypted.length() == 0 ) {
  return "";
 }
 BigInteger bi_confuse = new BigInteger( getSeed() );
 try {
  BigInteger bi_r1 = new BigInteger( encrypted, RADIX );
  BigInteger bi_r0 = bi_r1.xor( bi_confuse );
  return new String( bi_r0.toByteArray() );
 } catch ( Exception e ) {
  return "";
 }
}

代码示例来源:origin: ethereum/ethereumj

public byte[] calcDistance(Peer toPeer) {
  BigInteger aPeer = new BigInteger(getId());
  BigInteger bPeer = new BigInteger(toPeer.getId());
  BigInteger distance = aPeer.xor(bPeer);
  return BigIntegers.asUnsignedByteArray(distance);
}

代码示例来源:origin: org.codehaus.groovy/groovy

protected Number xorImpl(Number left, Number right) {
    return toBigInteger(left).xor(toBigInteger(right));
  }
}

代码示例来源:origin: jfaster/mango

private static BigInteger fnv1_32(byte[] data) {
 BigInteger hash = INIT32;
 for (byte b : data) {
  hash = hash.multiply(PRIME32).mod(MOD32);
  hash = hash.xor(BigInteger.valueOf((int) b & 0xff));
 }
 return hash;
}

代码示例来源:origin: hcoles/pitest

@Override
 BigInteger apply(BigInteger left, BigInteger right) {
  return left.xor(right);
 }
}

代码示例来源:origin: i2p/i2p.i2p

/** @return 0 to max-1 or -1 for us */
public int getRange(T key) {
  Integer rv;
  synchronized (_distanceCache) {
    rv = _distanceCache.get(key);
    if (rv == null) {
      // easy way when _bValue == 1
      //rv = Integer.valueOf(_bigUs.xor(new BigInteger(1, key.getData())).bitLength() - 1);
      BigInteger xor = _bigUs.xor(new BigInteger(1, key.getData()));
      int range = xor.bitLength() - 1;
      if (_bValue > 1) {
        int toShift = range + 1 - _bValue;
        int highbit = range;
        range <<= _bValue - 1;
        if (toShift >= 0) {
          int extra = xor.clearBit(highbit).shiftRight(toShift).intValue();
          range += extra;
          //Log log = I2PAppContext.getGlobalContext().logManager().getLog(KBucketSet.class);
          //if (log.shouldLog(Log.DEBUG))
          //    log.debug("highbit " + highbit + " toshift " + toShift + " extra " + extra + " new " + range);
        }
      }
      rv = Integer.valueOf(range);
      _distanceCache.put(key, rv);
    }
  }
  return rv.intValue();
}

代码示例来源:origin: killme2008/aviator

@Override
protected AviatorObject innerBitXor(AviatorObject other) {
 return AviatorBigInt.valueOf(this.toBigInt().xor(((AviatorNumber) other).toBigInt()));
}

代码示例来源:origin: org.apache.felix/org.apache.felix.gogo.runtime

@Override
  public BigDecimal eval(BigDecimal v1, BigDecimal v2) {
    return new BigDecimal(v1.toBigInteger().xor(v2.toBigInteger()), mc);
  }
});

代码示例来源:origin: org.apache.felix/org.apache.felix.gogo.runtime

@Override
  public BigDecimal eval(BigDecimal v1, BigDecimal v2) {
    return new BigDecimal(v1.toBigInteger().xor(v2.toBigInteger()), mc);
  }
});

代码示例来源:origin: apache/felix

@Override
  public BigDecimal eval(BigDecimal v1, BigDecimal v2) {
    return new BigDecimal(v1.toBigInteger().xor(v2.toBigInteger()), mc);
  }
});

代码示例来源:origin: weiboad/fiery

public int hammingDistance(SimHash other) {
  BigInteger m = new BigInteger("1").shiftLeft(this.hashbits).subtract(
      new BigInteger("1"));
  BigInteger x = this.strSimHash.xor(other.strSimHash).and(m);
  int tot = 0;
  while (x.signum() != 0) {
    tot += 1;
    x = x.and(x.subtract(new BigInteger("1")));
  }
  return tot;
}
/*public static void main(String[] args) {

代码示例来源:origin: org.apache.camel/camel-consul

private BigInteger getEventIndexFromId(Event event) {
    String eventId = event.getId();
    String lower = eventId.substring(0, 8) + eventId.substring(9, 13) + eventId.substring(14, 18);
    String upper = eventId.substring(19, 23) + eventId.substring(24, 36);
    BigInteger lowVal = new BigInteger(lower, 16);
    BigInteger highVal = new BigInteger(upper, 16);
    return lowVal.xor(highVal);
  }
}

代码示例来源:origin: org.armedbear.lisp/abcl

@Override
public LispObject LOGXOR(int n)
{
 return number(value.xor(BigInteger.valueOf(n)));
}

代码示例来源:origin: actiontech/dble

/**
 * xor's push-down is xor
 */
@Override
public boolean pushDownAdd(RowDataPacket row) {
  BigInteger value = args.get(0).valInt();
  if (!args.get(0).isNullValue())
    bits = bits.xor(value);
  return false;
}

代码示例来源:origin: actiontech/dble

@Override
public BigInteger valInt() {
  BigInteger arg1 = args.get(0).valInt();
  BigInteger arg2 = args.get(1).valInt();
  if (nullValue = (args.get(0).isNullValue() || args.get(1).isNullValue()))
    return BigInteger.ZERO;
  return arg1.xor(arg2);
}

代码示例来源:origin: RUB-NDS/TLS-Attacker

@Override
public FieldElement add(FieldElement f) {
  // Coefficients are added mod 2.
  BigInteger tmp = this.getData().xor(f.getData());
  return new FieldElementF2m(tmp, this.getModulus());
}

代码示例来源:origin: org.python/jython

@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rxor___doc)
final PyObject long___rxor__(PyObject left) {
  if (!canCoerce(left)) {
    return null;
  }
  return Py.newLong(coerce(left).xor(getValue()));
}

代码示例来源:origin: ognl/ognl

public static Object binaryXor(Object v1, Object v2)
{
  int type = getNumericType(v1, v2);
  if (type == BIGINT || type == BIGDEC) return bigIntValue(v1).xor(bigIntValue(v2));
  return newInteger(type, longValue(v1) ^ longValue(v2));
}

代码示例来源:origin: zycgit/hasor

/** 异或 */
public static Number xor(Number obj1, Number obj2) {
  checkDecimal(obj1, obj2);
  int numericType = getNumericType(obj1, obj2);
  if (numericType <= LONG) {
    return longValue(obj1) ^ longValue(obj2);
  } else {
    return bigIntValue(obj1).xor(bigIntValue(obj2));
  }
}
/** 左位移 */

相关文章