当前位置: 首页>>代码示例>>Java>>正文


Java Hex.toHexString方法代码示例

本文整理汇总了Java中org.spongycastle.util.encoders.Hex.toHexString方法的典型用法代码示例。如果您正苦于以下问题:Java Hex.toHexString方法的具体用法?Java Hex.toHexString怎么用?Java Hex.toHexString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongycastle.util.encoders.Hex的用法示例。


在下文中一共展示了Hex.toHexString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: storageHashCalc_1

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Test
public void storageHashCalc_1() {

    byte[] key1 = Hex.decode("0000000000000000000000000000000000000000000000000000000000000010");
    byte[] key2 = Hex.decode("0000000000000000000000000000000000000000000000000000000000000014");
    byte[] key3 = Hex.decode("0000000000000000000000000000000000000000000000000000000000000016");
    byte[] key4 = Hex.decode("0000000000000000000000000000000000000000000000000000000000000017");

    byte[] val1 = Hex.decode("947e70f9460402290a3e487dae01f610a1a8218fda");
    byte[] val2 = Hex.decode("40");
    byte[] val3 = Hex.decode("94412e0c4f0102f3f0ac63f0a125bce36ca75d4e0d");
    byte[] val4 = Hex.decode("01");

    TrieImpl storage = new TrieImpl();
    storage.put(key1, val1);
    storage.put(key2, val2);
    storage.put(key3, val3);
    storage.put(key4, val4);

    String hash = Hex.toHexString(storage.getRootHash());

    System.out.println(hash);
    Assert.assertEquals("517eaccda568f3fa24915fed8add49d3b743b3764c0bc495b19a47c54dbc3d62", hash);
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:25,代码来源:TrieTest.java

示例2: doBALANCE

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
protected void doBALANCE() {
    if (computeGas) {
        gasCost = GasCost.BALANCE;
        spendOpCodeGas();
    }
    // EXECUTION PHASE
    DataWord address = program.stackPop();
    DataWord balance = program.getBalance(address); // TODO: should not allocate

    if (isLogEnabled) {
        hint = "address: "
                + Hex.toHexString(address.getLast20Bytes())
                + " balance: " + balance.toString();
    }

    program.stackPush(balance);
    program.disposeWord(address);
    program.step();
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:20,代码来源:VM.java

示例3: testSha256_Multiple

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Test
public void testSha256_Multiple() {
    String expected1 = "1b4f0e9851971998e732078544c96b36c3d01cedf7caa332359d6f1d83567014";
    String result1 = Hex.toHexString(HashUtil.sha256("test1".getBytes()));
    assertEquals(expected1, result1);

    String expected2 = "60303ae22b998861bce3b28f33eec1be758a213c86c93c076dbe9f558c11c752";
    String result2 = Hex.toHexString(HashUtil.sha256("test2".getBytes()));
    assertEquals(expected2, result2);
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:11,代码来源:HashUtilTest.java

示例4: asString

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
private String asString(Object decoded) {
    if (decoded instanceof String) {
        return (String) decoded;
    } else if (decoded instanceof byte[]) {
        return Hex.toHexString((byte[]) decoded);
    } else if (decoded instanceof Object[]) {
        String result = "";
        for (Object item : (Object[]) decoded) {
            result += asString(item);
        }
        return result;
    }
    throw new RuntimeException("Not a valid type. Should not occur");
}
 
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:15,代码来源:DecodeResult.java

示例5: doRETURN

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
protected void doRETURN(){
    DataWord size;
    long sizeLong;
    long newMemSize ;

    size = stack.get(stack.size() - 2);

    if (computeGas) {
        gasCost = GasCost.RETURN;
        sizeLong = Program.limitToMaxLong(size);
        checkSizeArgument(sizeLong);
        newMemSize = memNeeded(stack.peek(), sizeLong);
        gasCost += calcMemGas(oldMemSize, newMemSize, 0);

        spendOpCodeGas();
    }
    // EXECUTION PHASE
    DataWord offset = program.stackPop();
    program.stackPop(); // pops size

    byte[] hReturn = program.memoryChunk(offset.intValue(), size.intValue());
    program.setHReturn(hReturn);

    if (isLogEnabled) {
        hint = "data: " + Hex.toHexString(hReturn)
                + " offset: " + offset.value()
                + " size: " + size.value();
    }

    program.step();
    program.disposeWord(offset);
    program.disposeWord(size);
    program.stop();
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:35,代码来源:VM.java

示例6: getTransactionCount

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Test
public void getTransactionCount() throws Exception {
    World world = new World();
    SimpleWorldManager worldManager = new SimpleWorldManager();
    worldManager.setBlockchain(world.getBlockChain());

    Web3Impl web3 = createWeb3(worldManager);
    web3.repository = (Repository) world.getRepository();

    Account acc1 = new AccountBuilder(world).name("acc1").balance(BigInteger.valueOf(100000000)).build();
    Account acc2 = new AccountBuilder().name("acc2").build();
    Transaction tx = new TransactionBuilder().sender(acc1).receiver(acc2).value(BigInteger.valueOf(1000000)).build();
    List<Transaction> txs = new ArrayList<>();
    txs.add(tx);
    Block genesis = world.getBlockChain().getBestBlock();
    Block block1 = new BlockBuilder(world).parent(genesis).transactions(txs).build();
    org.junit.Assert.assertEquals(ImportResult.IMPORTED_BEST, world.getBlockChain().tryToConnect(block1));

    String accountAddress = Hex.toHexString(acc1.getAddress().getBytes());

    String count = web3.eth_getTransactionCount(accountAddress, "0x1");

    Assert.assertNotNull(count);
    org.junit.Assert.assertEquals("0x1", count);

    count = web3.eth_getTransactionCount(accountAddress, "0x0");

    Assert.assertNotNull(count);
    org.junit.Assert.assertEquals("0x0", count);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:31,代码来源:Web3ImplTest.java

示例7: toString

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Override
public String toString() {
    return "AuthResponseMessage{" +
            "\n  ephemeralPublicKey=" + ephemeralPublicKey +
            "\n  nonce=" + Hex.toHexString(nonce) +
            "\n  version=" + version +
            '}';
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:9,代码来源:AuthResponseMessageV4.java

示例8: getBalanceWithAccountAndBlockWithTransaction

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Test
public void getBalanceWithAccountAndBlockWithTransaction() throws Exception {
    World world = new World();
    SimpleWorldManager worldManager = new SimpleWorldManager();
    worldManager.setBlockchain(world.getBlockChain());
    PendingState pendingState = new PendingStateImpl(ConfigHelper.CONFIG, world.getBlockChain(), world.getRepository(), world.getBlockChain().getBlockStore(), null, null, 10, 100);
    worldManager.setPendingState(pendingState);
    Account acc1 = new AccountBuilder(world).name("acc1").balance(BigInteger.valueOf(10000000)).build();
    Account acc2 = new AccountBuilder(world).name("acc2").build();
    Block genesis = world.getBlockByName("g00");

    Transaction tx = new TransactionBuilder().sender(acc1).receiver(acc2).value(BigInteger.valueOf(10000)).build();
    List<Transaction> txs = new ArrayList<>();
    txs.add(tx);
    Block block1 = new BlockBuilder(world).parent(genesis).transactions(txs).build();
    org.junit.Assert.assertEquals(ImportResult.IMPORTED_BEST, world.getBlockChain().tryToConnect(block1));

    Web3Impl web3 = createWeb3(worldManager);
    web3.repository = (Repository) world.getBlockChain().getRepository();

    String accountAddress = Hex.toHexString(acc2.getAddress().getBytes());
    String balanceString = "0x" + Hex.toHexString(BigInteger.valueOf(10000).toByteArray());

    org.junit.Assert.assertEquals("0x0", web3.eth_getBalance(accountAddress, "0x0"));
    org.junit.Assert.assertEquals(balanceString, web3.eth_getBalance(accountAddress, "0x1"));
    org.junit.Assert.assertEquals(balanceString, web3.eth_getBalance(accountAddress, "pending"));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:28,代码来源:Web3ImplTest.java

示例9: toHex

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
public String toHex() {
  return Hex.toHexString(toByteArray());
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:4,代码来源:ECKey.java

示例10: toString

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Override
public String toString() {
    return getType() + (dirty ? " *" : "") + (hash == null ? "" : "(hash: " + Hex.toHexString(hash) + " )");
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:5,代码来源:TrieImpl.java

示例11: toString

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Override
public String toString() {
    String ret = "  Code: " + (codes.size() < 2 ? Hex.toHexString(getCode()) : codes.size() + " versions" ) + "\n";
    ret += "  Storage: " + getStorage().toString();
    return ret;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:7,代码来源:AbstractContractDetails.java

示例12: toString

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Override
public String toString() {
    return Hex.toHexString(bytes);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:5,代码来源:RskAddress.java

示例13: processBlock

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
public void processBlock( Block block, Block parent) {
    latestStateRootHash = null;
    totalGasUsed = 0;
    totalPaidFees = BigInteger.ZERO;
    txReceipts = new ArrayList<>();

    //Repository originalRepo  = ((Repository) ethereum.getRepository()).getSnapshotTo(parent.getStateRoot());

    // This creates a snapshot WITHOUT history of the current "parent" reponsitory.
    Repository originalRepo  = repository.getSnapshotTo(parent.getStateRoot());

    Repository track = originalRepo.startTracking();

    // Repository track = new RepositoryTrack((Repository)ethereum.getRepository());

    // this variable is set before iterating transactions in case list is empty
    latestStateRootHash = originalRepo.getRoot();

    // RSK test, remove
    String stateHash1 = Hex.toHexString(blockchain.getBestBlock().getStateRoot());
    String stateHash2 = Hex.toHexString(repository.getRoot());
    if (stateHash1.compareTo(stateHash2) != 0) {
        logger.error("Strange state in block {} {}", block.getNumber(), Hex.toHexString(block.getHash()));
        panicProcessor.panic("minerserver", String.format("Strange state in block %d %s", block.getNumber(), Hex.toHexString(block.getHash())));
    }

    int txindex = 0;

    for (Transaction tx : block.getTransactionsList()) {

        TransactionExecutor executor = new TransactionExecutor(ConfigHelper.CONFIG, tx, txindex++, block.getCoinbase(),
                track, blockStore, blockchain.getReceiptStore(),
                programInvokeFactory, block, new EthereumListenerAdapter(), totalGasUsed);

        executor.init();
        executor.execute();
        executor.go();
        executor.finalization();

        long gasUsed = executor.getGasUsed();
        BigInteger paidFees = executor.getPaidFees();
        totalGasUsed += gasUsed;
        totalPaidFees = totalPaidFees.add(paidFees);

        track.commit();

        TransactionReceipt receipt = new TransactionReceipt();
        receipt.setGasUsed(gasUsed);
        receipt.setCumulativeGas(totalGasUsed);
        latestStateRootHash = originalRepo.getRoot();
        receipt.setPostTxState(latestStateRootHash);
        receipt.setTxStatus(executor.getReceipt().isSuccessful());
        receipt.setStatus(executor.getReceipt().getStatus());
        receipt.setTransaction(tx);
        receipt.setLogInfoList(executor.getVMLogs());

        txReceipts.add(receipt);

    }
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:61,代码来源:MinerHelper.java

示例14: toString

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Override
public String toString() {
    return Hex.toHexString(data);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:5,代码来源:ByteArrayWrapper.java

示例15: str

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
private String str(Object obj) {
    if (obj == null) return null;
    return Hex.toHexString((byte[]) obj);
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:5,代码来源:ReadWriteCacheTest.java


注:本文中的org.spongycastle.util.encoders.Hex.toHexString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。