本文整理匯總了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;
}