当前位置: 首页>>代码示例>>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;未经允许,请勿转载。