本文整理了Java中org.bitcoinj.core.Utils.readUint32BE()
方法的一些代码示例,展示了Utils.readUint32BE()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.readUint32BE()
方法的具体详情如下:
包路径:org.bitcoinj.core.Utils
类名称:Utils
方法名:readUint32BE
[英]Parse 4 bytes from the byte array (starting at the offset) as unsigned 32-bit integer in big endian format.
[中]将字节数组中的4个字节(从偏移量开始)解析为big-endian格式的无符号32位整数。
代码示例来源:origin: blockchain/unused-My-Wallet-V3-jar
/**
* BIP 43 purpose needs to be 31 bit or less. For lack of a BIP number we take the first 31 bits
* of the SHA256 hash of a reverse domain.
*/
private static int getPurpose(String sub) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md = MessageDigest.getInstance("SHA-256");
String text = "info.blockchain."+sub;
md.update(text.getBytes("UTF-8"));
byte[] hash = md.digest();
byte[] slice = Arrays.copyOfRange(hash, 0, 4);
return (int) (Utils.readUint32BE(slice, 0) & 0x7FFFFFFF); // 510742
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* MPI encoded numbers are produced by the OpenSSL BN_bn2mpi function. They consist of
* a 4 byte big endian length field, followed by the stated number of bytes representing
* the number in big endian format (with a sign bit).
* @param hasLength can be set to false if the given array is missing the 4 byte length field
*/
public static BigInteger decodeMPI(byte[] mpi, boolean hasLength) {
byte[] buf;
if (hasLength) {
int length = (int) readUint32BE(mpi, 0);
buf = new byte[length];
System.arraycopy(mpi, 4, buf, 0, length);
} else
buf = mpi;
if (buf.length == 0)
return BigInteger.ZERO;
boolean isNegative = (buf[0] & 0x80) == 0x80;
if (isNegative)
buf[0] &= 0x7f;
BigInteger result = new BigInteger(buf);
return isNegative ? result.negate() : result;
}
代码示例来源:origin: greenaddress/GreenBits
/**
* MPI encoded numbers are produced by the OpenSSL BN_bn2mpi function. They consist of
* a 4 byte big endian length field, followed by the stated number of bytes representing
* the number in big endian format (with a sign bit).
* @param hasLength can be set to false if the given array is missing the 4 byte length field
*/
public static BigInteger decodeMPI(byte[] mpi, boolean hasLength) {
byte[] buf;
if (hasLength) {
int length = (int) readUint32BE(mpi, 0);
buf = new byte[length];
System.arraycopy(mpi, 4, buf, 0, length);
} else
buf = mpi;
if (buf.length == 0)
return BigInteger.ZERO;
boolean isNegative = (buf[0] & 0x80) == 0x80;
if (isNegative)
buf[0] &= 0x7f;
BigInteger result = new BigInteger(buf);
return isNegative ? result.negate() : result;
}
代码示例来源:origin: HashEngineering/dashj
/**
* MPI encoded numbers are produced by the OpenSSL BN_bn2mpi function. They consist of
* a 4 byte big endian length field, followed by the stated number of bytes representing
* the number in big endian format (with a sign bit).
* @param hasLength can be set to false if the given array is missing the 4 byte length field
*/
public static BigInteger decodeMPI(byte[] mpi, boolean hasLength) {
byte[] buf;
if (hasLength) {
int length = (int) readUint32BE(mpi, 0);
buf = new byte[length];
System.arraycopy(mpi, 4, buf, 0, length);
} else
buf = mpi;
if (buf.length == 0)
return BigInteger.ZERO;
boolean isNegative = (buf[0] & 0x80) == 0x80;
if (isNegative)
buf[0] &= 0x7f;
BigInteger result = new BigInteger(buf);
return isNegative ? result.negate() : result;
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* MPI encoded numbers are produced by the OpenSSL BN_bn2mpi function. They consist of
* a 4 byte big endian length field, followed by the stated number of bytes representing
* the number in big endian format (with a sign bit).
* @param hasLength can be set to false if the given array is missing the 4 byte length field
*/
public static BigInteger decodeMPI(byte[] mpi, boolean hasLength) {
byte[] buf;
if (hasLength) {
int length = (int) readUint32BE(mpi, 0);
buf = new byte[length];
System.arraycopy(mpi, 4, buf, 0, length);
} else
buf = mpi;
if (buf.length == 0)
return BigInteger.ZERO;
boolean isNegative = (buf[0] & 0x80) == 0x80;
if (isNegative)
buf[0] &= 0x7f;
BigInteger result = new BigInteger(buf);
return isNegative ? result.negate() : result;
}
代码示例来源:origin: fr.acinq/bitcoinj-core
long size = Utils.readUint32BE(Utils.reverseBytes(bytes), 0);
代码示例来源:origin: HashEngineering/dashj
long size = Utils.readUint32BE(Utils.reverseBytes(bytes), 0);
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
long size = Utils.readUint32BE(Utils.reverseBytes(bytes), 0);
代码示例来源:origin: greenaddress/GreenBits
long size = Utils.readUint32BE(Utils.reverseBytes(bytes), 0);
内容来源于网络,如有侵权,请联系作者删除!