當前位置: 首頁>>代碼示例>>Java>>正文


Java Bytes.concat方法代碼示例

本文整理匯總了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;
}
 
開發者ID:digital-voting-pass,項目名稱:polling-station-app,代碼行數:40,代碼來源:PassportTransactionFormatter.java

示例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;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:12,代碼來源:PaddingTlv.java

示例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;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:9,代碼來源:Csnp.java

示例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;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:15,代碼來源:UnreservedBandwidth.java

示例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;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:15,代碼來源:TrafficEngineeringMetric.java

示例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");
  }
}
 
開發者ID:google,項目名稱:webauthndemo,代碼行數:33,代碼來源:AuthenticatorDataTest.java

示例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;
       }
}
 
開發者ID:mateuszk87,項目名稱:BadIntent,代碼行數:14,代碼來源:BadIntentMessageEditorTab.java

示例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);
    }
}
 
開發者ID:gchq,項目名稱:stroom-stats,代碼行數:16,代碼來源:TestEventStoreTimeIntervalEnum.java

示例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;

}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:15,代碼來源:MaximumReservableBandwidth.java

示例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);
    }
}
 
開發者ID:eclipse,項目名稱:keti,代碼行數:14,代碼來源:Encryptor.java

示例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);
	}
 
開發者ID:dcsolutions,項目名稱:kalinka,代碼行數:8,代碼來源:MqttMqttJmsMessagePublisher.java

示例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);
  }
}
 
開發者ID:wpilibsuite,項目名稱:shuffleboard,代碼行數:12,代碼來源:Serialization.java

示例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;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:30,代碼來源:RedundantKVGenerator.java

示例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;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:10,代碼來源:IsReachabilityTlv.java

示例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;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:11,代碼來源:IpExtendedReachabilityTlv.java


注:本文中的com.google.common.primitives.Bytes.concat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。