当前位置: 首页>>代码示例>>Java>>正文


Java BigInteger.xor方法代码示例

本文整理汇总了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);
}
 
开发者ID:fergarrui,项目名称:ethereum-bytecode-analyzer,代码行数:19,代码来源:Xor.java

示例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;
}
 
开发者ID:sheraz-n,项目名称:Cryptguard,代码行数:17,代码来源:F2m.java

示例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);
	}
}
 
开发者ID:EonTechnology,项目名称:server,代码行数:18,代码来源:Format.java

示例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();
}
 
开发者ID:EonTechnology,项目名称:server,代码行数:17,代码来源:NodeHelper.java

示例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);
    }
 
开发者ID:talentchain,项目名称:talchain,代码行数:9,代码来源:Peer.java

示例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);
}
 
开发者ID:sheraz-n,项目名称:Cryptguard,代码行数:16,代码来源:F2m.java

示例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();
		}
 
开发者ID:EonTechnology,项目名称:server,代码行数:32,代码来源:Format.java

示例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);
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:11,代码来源:VarInt.java

示例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);
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:11,代码来源:VarInt.java

示例10: modifyImplementationHook

import java.math.BigInteger; //导入方法依赖的package包/类
@Override
protected BigInteger modifyImplementationHook(BigInteger input) {
    if (input == null) {
        input = BigInteger.ZERO;
    }
    return input.xor(xor);
}
 
开发者ID:RUB-NDS,项目名称:ModifiableVariable,代码行数:8,代码来源:BigIntegerXorModification.java

示例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);
}
 
开发者ID:actiontech,项目名称:dble,代码行数:9,代码来源:ItemFuncBitXor.java

示例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;
}
 
开发者ID:TypingDNA,项目名称:TypingDnaRecorder-Java,代码行数:10,代码来源:TypingDNARecorder.java

示例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);
}
 
开发者ID:JungleTree,项目名称:JungleTree,代码行数:6,代码来源:ByteBufUtils.java

示例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);
}
 
开发者ID:JungleTree,项目名称:JungleTree,代码行数:7,代码来源:ByteBufUtils.java

示例15: revert

import java.math.BigInteger; //导入方法依赖的package包/类
@Override
public BigInteger revert(BigInteger value, BigInteger constantInt) throws TraceException {
    return value.xor(constantInt);
}
 
开发者ID:fergarrui,项目名称:ethereum-bytecode-analyzer,代码行数:5,代码来源:XorRevert.java


注:本文中的java.math.BigInteger.xor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。