本文整理汇总了Java中com.google.common.primitives.Bytes.concat方法的典型用法代码示例。如果您正苦于以下问题:Java Bytes.concat方法的具体用法?Java Bytes.concat怎么用?Java Bytes.concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.primitives.Bytes
的用法示例。
在下文中一共展示了Bytes.concat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: signRawTransaction
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
/**
* Signs the raw bytes using a travel document.
* Follows the steps in this answer: https://bitcoin.stackexchange.com/a/5241
* @return signedRawTransaction
*/
public byte[] signRawTransaction(PublicKey pubkey, byte[][] parts, PassportConnection pcon) throws Exception {
byte[] rawTransaction = Bytes.concat(parts[0], parts[1], parts[2], parts[3], parts[4], parts[5],
parts[6], parts[7], parts[8], parts[9], parts[10], parts[11], parts[12]);
// Double hash transaction
byte[] step14 = Sha256Hash.hash(Sha256Hash.hash(rawTransaction));
// Generate signature and get publickey
byte[] multiSignature = new byte[320];
byte[] hashPart;
for (int i = 0; i < 4; i++) {
hashPart = Arrays.copyOfRange(step14, i * 8, i * 8 + 8);
System.arraycopy(pcon.signData(hashPart), 0, multiSignature, i * 80, 80);
}
byte[] signatureLength = Util.hexStringToByteArray("fd97014d4101");
byte[] hashCodeType = Util.hexStringToByteArray("01");
byte[] publicKeyASN = pubkey.getEncoded();
byte[] publicKey = new byte[81];
System.arraycopy(publicKeyASN, publicKeyASN.length-81, publicKey, 0, 81);
byte[] publickeyLength = Util.hexStringToByteArray("4c51");
// Set signature and pubkey in format
byte[] step16 = Bytes.concat(signatureLength, multiSignature, hashCodeType, publickeyLength, publicKey);
// Update transaction with signature and remove hash code type
byte[] step19 = Bytes.concat(parts[0], parts[1], parts[2], parts[3], step16, parts[6],
parts[7], parts[8], parts[9], parts[10], parts[11], parts[12]);
return step19;
}
示例2: asBytes
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
@Override
public byte[] asBytes() {
byte[] bytes = null;
byte[] tlvHeader = tlvHeaderAsByteArray();
byte[] tlvBody = tlvBodyAsBytes();
tlvHeader[1] = (byte) tlvBody.length;
bytes = Bytes.concat(tlvHeader, tlvBody);
return bytes;
}
示例3: asBytes
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
@Override
public byte[] asBytes() {
byte[] csnpMessage = null;
byte[] isisPduHeader = isisPduHeader();
byte[] csnpBody = completeSequenceNumberPduBody();
csnpMessage = Bytes.concat(isisPduHeader, csnpBody);
return csnpMessage;
}
示例4: asBytes
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
/**
* Gets instance as byte array.
*
* @return instance as byte array
*/
public byte[] asBytes() {
byte[] linkSubType = null;
byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
byte[] linkSubTlvBody = getLinkSubTypeTlvBodyAsByteArray();
linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
return linkSubType;
}
示例5: asBytes
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
/**
* Returns instance as byte array.
*
* @return instance as byte array
*/
public byte[] asBytes() {
byte[] linkSubType = null;
byte[] linkSubTlvHeader = tlvHeaderAsByteArray();
byte[] linkSubTlvBody = tlvBodyAsBytes();
linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
return linkSubType;
}
示例6: testDecodeWithAttestation
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
/**
* Test method for {@link com.google.webauthn.gaedemo.objects.AuthenticatorData#decode(byte[])}.
*/
@Test
public void testDecodeWithAttestation() {
byte[] randomRpIdHash = new byte[32];
random.nextBytes(randomRpIdHash);
byte[] flags = {1 << 6};
AttestationData attData = new AttestationData();
EccKey eccKey = new EccKey(Base64.getDecoder().decode("NNxD3LBXs6iF1jiBGZ4Qqhd997NKcmDLJyyILL49V90"),
Base64.getDecoder().decode("MJtVZlRRfTscLy06DSHLBfA8O03pZJ1K01DbCILr0rA"));
random.nextBytes(attData.aaguid);
eccKey.alg = Algorithm.ES256;
attData.publicKey = eccKey;
int countInt = random.nextInt(Integer.MAX_VALUE);
byte[] count = ByteBuffer.allocate(4).putInt(countInt).array();
byte[] data = null;
try {
data = Bytes.concat(randomRpIdHash, flags, count, attData.encode());
} catch (CborException e1) {
fail("Failed during Cbor encoding");
}
try {
AuthenticatorData result = AuthenticatorData.decode(data);
assertTrue(result.getAttData().getPublicKey().equals(eccKey));
assertArrayEquals(randomRpIdHash, result.getRpIdHash());
assertEquals(countInt, result.getSignCount());
} catch (ResponseException e) {
fail("Exception occurred");
}
}
示例7: getMessage
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
@Override
public byte[] getMessage() {
List<ParcelOperationDAO> parcelOperationDaos = overview.retrievedParcelOperations();
if (isModified()) {
parcelPoolElementDao.operations = parcelOperationDaos;
String responseBody = new GsonBuilder().create().toJson(parcelPoolElementDao);
int bodyStart = requestInfo.getBodyOffset();
byte[] header = Arrays.copyOfRange(content, 0, bodyStart);
return Bytes.concat(header, responseBody.getBytes());
} else {
return content;
}
}
示例8: testSerializationDeserialization2
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
/**
* Deserialize from a bigger byte array where the interval is just part of it.
*/
@Test
public void testSerializationDeserialization2() throws Exception {
for (final EventStoreTimeIntervalEnum interval : EventStoreTimeIntervalEnum.values()) {
byte[] bytes = interval.getByteVal();
int paddingSize = 10;
byte[] padding = new byte[paddingSize];
byte[] bigByteArray = Bytes.concat(padding, bytes);
EventStoreTimeIntervalEnum interval2 = EventStoreTimeIntervalEnum.fromBytes(bigByteArray, paddingSize);
Assertions.assertThat(interval).isEqualTo(interval2);
}
}
示例9: asBytes
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
/**
* Returns byte array of maximum reservable bandwidth.
*
* @return byte array of maximum reservable bandwidth
*/
public byte[] asBytes() {
byte[] linkSubType = null;
byte[] linkSubTlvHeader = getTlvHeaderAsByteArray();
byte[] linkSubTlvBody = getLinksubTypeTlvBodyAsByteArray();
linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody);
return linkSubType;
}
示例10: encrypt
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
public String encrypt(final String value) {
try {
byte[] ivBytes = new byte[IV_LENGTH_IN_BYTES];
new SecureRandom().nextBytes(ivBytes);
byte[] encrypted = this.buildCipher(ivBytes, Cipher.ENCRYPT_MODE).doFinal(value.getBytes(CHARSET_NAME));
byte[] result = Bytes.concat(ivBytes, encrypted);
return Base64.encodeBase64String(result);
} catch (Exception e) {
throw new EncryptionFailureException("Unable to encrypt", e);
}
}
示例11: getEnrichedPayload
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
byte[] getEnrichedPayload(final byte[] effectivePayload, final String srcId) {
final byte[] headerBytes = ("{\"srcId\": \"" + srcId + "\"}").getBytes(StandardCharsets.UTF_8);
final byte[] header = new byte[64];
System.arraycopy(headerBytes, 0, header, 0, headerBytes.length);
return Bytes.concat(header, effectivePayload);
}
示例12: toByteArray
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
/**
* Encodes a string as a big-endian byte array. The resulting array encodes the length of the string in the first
* four bytes, then the contents of the string.
*/
public static byte[] toByteArray(String string) {
try {
return Bytes.concat(toByteArray(string.length()), string.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new AssertionError("UTF-8 is not supported (the JVM is not to spec!)", e);
}
}
示例13: generateRows
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
private List<byte[]> generateRows() {
// generate prefixes
List<byte[]> prefixes = new ArrayList<byte[]>();
prefixes.add(new byte[0]);
for (int i = 1; i < numberOfRowPrefixes; ++i) {
int prefixLength = averagePrefixLength;
prefixLength += randomizer.nextInt(2 * prefixLengthVariance + 1) -
prefixLengthVariance;
byte[] newPrefix = new byte[prefixLength];
randomizer.nextBytes(newPrefix);
byte[] newPrefixWithCommon = newPrefix;
prefixes.add(newPrefixWithCommon);
}
// generate rest of the row
List<byte[]> rows = new ArrayList<byte[]>();
for (int i = 0; i < numberOfRows; ++i) {
int suffixLength = averageSuffixLength;
suffixLength += randomizer.nextInt(2 * suffixLengthVariance + 1) -
suffixLengthVariance;
int randomPrefix = randomizer.nextInt(prefixes.size());
byte[] row = new byte[prefixes.get(randomPrefix).length +
suffixLength];
byte[] rowWithCommonPrefix = Bytes.concat(commonPrefix, row);
rows.add(rowWithCommonPrefix);
}
return rows;
}
示例14: asBytes
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
@Override
public byte[] asBytes() {
byte[] bytes = null;
byte[] tlvHeader = tlvHeaderAsByteArray();
byte[] tlvBody = tlvBodyAsBytes();
tlvHeader[1] = (byte) tlvBody.length;
bytes = Bytes.concat(tlvHeader, tlvBody);
return bytes;
}
示例15: asBytes
import com.google.common.primitives.Bytes; //导入方法依赖的package包/类
@Override
public byte[] asBytes() {
byte[] bytes = null;
byte[] tlvHeader = tlvHeaderAsByteArray();
byte[] tlvBody = tlvBodyAsBytes();
tlvHeader[1] = (byte) tlvBody.length;
bytes = Bytes.concat(tlvHeader, tlvBody);
return bytes;
}