本文整理汇总了Java中java.math.BigInteger.xor方法的典型用法代码示例。如果您正苦于以下问题:Java BigInteger.xor方法的具体用法?Java BigInteger.xor怎么用?Java BigInteger.xor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.math.BigInteger
的用法示例。
在下文中一共展示了BigInteger.xor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import java.math.BigInteger; //导入方法依赖的package包/类
@Override
public void execute(EVMState state, Opcode opcode) throws EVMException {
EVMStack stack = state.getStack();
TraceableWord traceableWord0 = stack.pop();
TraceableWord traceableWord1 = stack.pop();
BigInteger element0 = new BigInteger(traceableWord0.getBytes());
BigInteger element1 = new BigInteger(traceableWord1.getBytes());
BigInteger result = element0.xor(element1);
TraceableWord resultTraceableWord = new TraceableWord(result.toByteArray());
TraceTree traceTree = buildTraceTree(opcode, resultTraceableWord, Lists.of(traceableWord0, traceableWord1));
traceTree.addChild(traceableWord0.getTrace());
traceTree.addChild(traceableWord1.getTrace());
resultTraceableWord.setTrace(traceTree);
stack.push(resultTraceableWord);
}
示例2: F2x_mod
import java.math.BigInteger; //导入方法依赖的package包/类
private static BigInteger F2x_mod(BigInteger a)
throws ArithmeticException {
BigInteger r = BigInteger.valueOf(0);
if (modulus.compareTo(BigInteger.valueOf(0)) == 0)
throw new ArithmeticException("F2m.F2x_mod: modulus is zero");
if (a.compareTo(modulus) < 0)
return a;
else if (a.compareTo(modulus) == 0)
return r;
r = a;
while (r.bitLength() >= modulus.bitLength()) {
r = r.xor(modulus.shiftLeft(r.bitLength() - modulus.bitLength()));
}
return r;
}
示例3: pick
import java.math.BigInteger; //导入方法依赖的package包/类
public static long pick(byte[] bytes, int timestamp) {
try {
byte[] hash = MessageDigest.getInstance(MessageDigestAlgorithm).digest(bytes);
BigInteger bigInteger = BigInteger.ZERO;
for (int i = 0; i < hash.length; i += 4) {
BigInteger bi = new BigInteger(1, new byte[]{hash[i + 3], hash[i + 2], hash[i + 1], hash[i]});
bigInteger = bigInteger.xor(bi);
}
long val = ((long) bigInteger.intValue() << 32) | ((long) timestamp & 0xFFFFFFFL);
return val;
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
示例4: getIndex
import java.math.BigInteger; //导入方法依赖的package包/类
private static long getIndex(String key) {
byte[] bytes = key.getBytes();
if (bytes.length % 8 != 0) {
bytes = Arrays.copyOf(bytes, ((bytes.length % 8) + 1) * 4);
}
BigInteger bigInteger = BigInteger.ZERO;
for (int i = 0; i < bytes.length; i += 8) {
BigInteger bi = new BigInteger(1, new byte[]{bytes[i + 7], bytes[i + 6], bytes[i + 5], bytes[i + 4],
bytes[i + 3], bytes[i + 2], bytes[i + 1], bytes[i]});
bigInteger = bigInteger.xor(bi);
}
return bigInteger.longValue();
}
示例5: calcDistance
import java.math.BigInteger; //导入方法依赖的package包/类
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);
}
示例6: F2x_mul
import java.math.BigInteger; //导入方法依赖的package包/类
/**
* Algorithm 2 in "Software Implementation of Elliptic Curve Cryptography
* Over Binary Fields", D. Hankerson, J.L. Hernandez, A. Menezes.
*/
protected static BigInteger F2x_mul(BigInteger a, BigInteger b) {
BigInteger c = BigInteger.valueOf(0);
for (int j = 0; j < a.bitLength(); j++) {
if (a.testBit(j)) {
c = c.xor(b);
}
b = b.shiftLeft(1);
}
return F2x_mod(c);
}
示例7: Encode
import java.math.BigInteger; //导入方法依赖的package包/类
static String Encode(long plain, final String prefix) {
BigInteger id = BigInteger.valueOf(plain);
if (plain < 0) {
id = id.add(Format.two64);
}
BigInteger chs = BigInteger.ZERO;
BigInteger andVal = BigInteger.valueOf(0x3FF);
BigInteger tmp = id;
while (tmp.compareTo(BigInteger.ZERO) > 0) {
chs = chs.xor(tmp.and(andVal));
tmp = tmp.shiftRight(10);
}
id = id.or(chs.shiftLeft(64));
id = id.setBit(74);
StringBuilder idStr = new StringBuilder(prefix);
andVal = BigInteger.valueOf(0x1F);
for (int i = 0; i < 15; i++) {
if ((i % 5) == 0) {
idStr.append('-');
}
idStr.append(alphabet.charAt(id.and(andVal).intValue()));
id = id.shiftRight(5);
}
return idStr.toString();
}
示例8: encodeZigZag64
import java.math.BigInteger; //导入方法依赖的package包/类
/**
* @param v Signed long
* @return Unsigned encoded long
*/
public static BigInteger encodeZigZag64(long v) {
BigInteger origin = BigInteger.valueOf(v);
BigInteger left = origin.shiftLeft(1);
BigInteger right = origin.shiftRight(63);
return left.xor(right);
}
示例9: decodeZigZag64
import java.math.BigInteger; //导入方法依赖的package包/类
/**
* @param v Unsigned encoded long
* @return Unsigned decoded long
*/
public static BigInteger decodeZigZag64(BigInteger v) {
_assert(v);
BigInteger left = v.shiftRight(1);
BigInteger right = v.and(BigInteger.ONE).negate();
return left.xor(right);
}
示例10: modifyImplementationHook
import java.math.BigInteger; //导入方法依赖的package包/类
@Override
protected BigInteger modifyImplementationHook(BigInteger input) {
if (input == null) {
input = BigInteger.ZERO;
}
return input.xor(xor);
}
示例11: valInt
import java.math.BigInteger; //导入方法依赖的package包/类
@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);
}
示例12: fnv1a_32
import java.math.BigInteger; //导入方法依赖的package包/类
private static BigInteger fnv1a_32(byte[] data) {
BigInteger hash = new BigInteger("721b5ad4", 16);
;
for (byte b : data) {
hash = hash.xor(BigInteger.valueOf((int) b & 0xff));
hash = hash.multiply(new BigInteger("01000193", 16)).mod(new BigInteger("2").pow(32));
}
return hash;
}
示例13: decodeZigZag64
import java.math.BigInteger; //导入方法依赖的package包/类
private static BigInteger decodeZigZag64(BigInteger value) {
BigInteger mostSigBits = value.shiftRight(1);
BigInteger leastSigBits = value.and(BigInteger.ONE).negate();
return mostSigBits.xor(leastSigBits);
}
示例14: encodeZigZag64
import java.math.BigInteger; //导入方法依赖的package包/类
private static BigInteger encodeZigZag64(long value) {
BigInteger origin = BigInteger.valueOf(value);
BigInteger left = origin.shiftLeft(1);
BigInteger right = origin.shiftRight(63);
return left.xor(right);
}
示例15: revert
import java.math.BigInteger; //导入方法依赖的package包/类
@Override
public BigInteger revert(BigInteger value, BigInteger constantInt) throws TraceException {
return value.xor(constantInt);
}