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


Java Hex.decode方法代码示例

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


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

示例1: init

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
private void init(JSONArray jLogs) {
    logs = new ArrayList<>();
    for (Object jLog1 : jLogs) {

        JSONObject jLog = (JSONObject) jLog1;
        byte[] address = Hex.decode((String) jLog.get("address"));
        byte[] data = Hex.decode(((String) jLog.get("data")).substring(2));

        List<DataWord> topics = new ArrayList<>();

        JSONArray jTopics = (JSONArray) jLog.get("topics");
        for (Object t : jTopics.toArray()) {
            byte[] topic = Hex.decode(((String) t));
            topics.add(new DataWord(topic));
        }

        LogInfo li = new LogInfo(address, topics, data);
        logs.add(li);
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:21,代码来源:Logs.java

示例2: test18

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

    RepositoryRoot repository = new RepositoryRoot(new HashMapDB());
    Repository repoTrack2 = repository.startTracking(); //track

    byte[] cow = Hex.decode("CD2A3D9F938E13CD947EC05ABC7FE734DF8DD826");
    byte[] horse = Hex.decode("13978AEE95F38490E9769C39B2773ED763D9CD5F");
    byte[] pig = Hex.decode("F0B8C9D84DD2B877E0B952130B73E218106FEC04");
    byte[] precompiled = Hex.decode("0000000000000000000000000000000000000002");

    byte[] cowCode = Hex.decode("A1A2A3");
    byte[] horseCode = Hex.decode("B1B2B3");

    repository.saveCode(cow, cowCode);
    repository.saveCode(horse, horseCode);

    repository.delete(horse);

    assertEquals(true, repoTrack2.isExist(cow));
    assertEquals(false, repoTrack2.isExist(horse));
    assertEquals(false, repoTrack2.isExist(pig));
    assertEquals(false, repoTrack2.isExist(precompiled));
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:25,代码来源:RepositoryTest.java

示例3: testMLOAD_4

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

    VM vm = new VM(ConfigHelper.CONFIG);
    program = new Program(ConfigHelper.CONFIG, Hex.decode("611234602052602051"), invoke);
    String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" +
            "0000000000000000000000000000000000000000000000000000000000001234";
    String s_expected = "0000000000000000000000000000000000000000000000000000000000001234";

    vm.step(program);
    vm.step(program);
    vm.step(program);
    vm.step(program);
    vm.step(program);

    assertEquals(m_expected, Hex.toHexString(program.getMemory()));
    assertEquals(s_expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:19,代码来源:VMTest.java

示例4: testMulMod1

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Test
public void testMulMod1() {
    DataWord wr = new DataWord(Hex.decode("9999999999999999999999999999999999999999999999999999999999999999"));
    DataWord w1 = new DataWord(Hex.decode("01"));
    DataWord w2 = new DataWord(Hex.decode("9999999999999999999999999999999999999999999999999999999999999998"));

    wr.mulmod(w1, w2);

    assertEquals(32, wr.getData().length);
    assertEquals("0000000000000000000000000000000000000000000000000000000000000001", Hex.toHexString(wr.getData()));
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:12,代码来源:DataWordTest.java

示例5: testSUB_3

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

    VM vm = new VM();
    program = new Program(Hex.decode("614444639999666603"), invoke);
    String s_expected_1 = "0000000000000000000000000000000000000000000000000000000099992222";

    vm.step(program);
    vm.step(program);
    vm.step(program);

    DataWord item1 = program.stackPop();
    assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase());
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:15,代码来源:VMTest.java

示例6: test1

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

    byte[] payload = Hex.decode("f84927808425c60144a0832056d3c93ff2739ace7199952e5365aa29f18805be05634c4db125c5340216a0955f36d073ccb026b78ab3424c15cf966a7563aa270413859f78702b9e8e22cb");
    StatusMessage statusMessage = new StatusMessage(payload);

    logger.info(statusMessage.toString());

    assertEquals(39, statusMessage.getProtocolVersion());
    assertEquals("25c60144",
            Hex.toHexString(statusMessage.getTotalDifficulty()));
    assertEquals("832056d3c93ff2739ace7199952e5365aa29f18805be05634c4db125c5340216",
            Hex.toHexString(statusMessage.getBestHash()));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:15,代码来源:StatusMessageTest.java

示例7: testMSTORE8_4

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Test(expected = StackTooSmallException.class) // MSTORE8 OP mal
public void testMSTORE8_4() {

    VM vm = new VM();
    program = new Program(Hex.decode("602253"), invoke);
    try {
        vm.step(program);
        vm.step(program);
    } finally {
        assertTrue(program.isStopped());
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:13,代码来源:VMTest.java

示例8: testADDMOD_3

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Test // ADDMOD OP
public void testADDMOD_3() {
    VM vm = new VM(ConfigHelper.CONFIG);
    program = new Program(ConfigHelper.CONFIG, Hex.decode("61100265123456789009600208"), invoke);
    String s_expected_1 = "000000000000000000000000000000000000000000000000000000000000093B";

    vm.step(program);
    vm.step(program);
    vm.step(program);
    vm.step(program);

    DataWord item1 = program.stackPop();
    assertTrue(program.isStopped());
    assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:16,代码来源:VMTest.java

示例9: testNOT_5

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Test  // NOT OP test from real failure
public void testNOT_5() {

    VM vm = new VM();
    program = new Program(Hex.decode("600019"), invoke);
    String expected = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";

    vm.step(program);
    vm.step(program);

    assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase());
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:13,代码来源:VMTest.java

示例10: testSWAPN_2

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Test(expected = StackTooSmallException.class)  // SWAPN OP mal data
public void testSWAPN_2() {

    VM vm = new VM();
    program = new Program(Hex.decode("90"), invoke);

    try {
        vm.step(program);
    } finally {
        assertTrue(program.isStopped());
    }
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:13,代码来源:VMTest.java

示例11: testPUSH17

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

    VM vm = new VM();
    program = new Program(Hex.decode("70A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2"), invoke);
    String expected = "000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2";

    program.fullTrace();
    vm.step(program);

    assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase());
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:13,代码来源:VMTest.java

示例12: test3

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

    DatabaseImpl db = new DatabaseImpl(new HashMapDB());
    DetailsDataStore dds = new DetailsDataStore(ConfigHelper.CONFIG);
    dds.setDB(db);

    byte[] c_key = Hex.decode("1a2b");
    byte[] code = Hex.decode("60606060");
    byte[] key =  Hex.decode("11");
    byte[] value =  Hex.decode("aa");

    ContractDetails contractDetails = new ContractDetailsImpl(ConfigHelper.CONFIG);
    contractDetails.setCode(code);
    contractDetails.put(new DataWord(key), new DataWord(value));

    dds.update(c_key, contractDetails);

    ContractDetails contractDetails_ = dds.get(c_key);

    String encoded1 = Hex.toHexString(contractDetails.getEncoded());
    String encoded2 = Hex.toHexString(contractDetails_.getEncoded());

    assertEquals(encoded1, encoded2);

    dds.remove(c_key);
    dds.update(c_key, contractDetails);

    contractDetails_ = dds.get(c_key);
    encoded2 = Hex.toHexString(contractDetails_.getEncoded());
    assertEquals(encoded1, encoded2);

    dds.flush();

    contractDetails_ = dds.get(c_key);
    encoded2 = Hex.toHexString(contractDetails_.getEncoded());
    assertEquals(encoded1, encoded2);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:39,代码来源:DetailsDataStoreTest.java

示例13: testEXTCODECOPY_5

import org.spongycastle.util.encoders.Hex; //导入方法依赖的package包/类
@Test(expected = StackTooSmallException.class) // EXTCODECOPY OP mal
public void testEXTCODECOPY_5() {
    VM vm = new VM();
    program =
            new Program(Hex.decode("605E600773471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C"),
                    invoke);
    try {
        vm.step(program);
        vm.step(program);
        vm.step(program);
        vm.step(program);
    } finally {
        assertTrue(program.isStopped());
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:16,代码来源:VMTest.java

示例14: testPUSH5

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

    VM vm = new VM();
    program = new Program(Hex.decode("64A0B0C0D0E0"), invoke);
    String expected = "000000000000000000000000000000000000000000000000000000A0B0C0D0E0";

    program.fullTrace();
    vm.step(program);

    assertEquals(expected, Hex.toHexString(program.getStack().peek().getData()).toUpperCase());
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:13,代码来源:VMTest.java

示例15: test_1

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

    byte[] payload = Hex.decode("f90144f9013Bf90136a0d8faffbc4c4213d35db9007de41cece45d95db7fd6c0f129e158baa888c48eefa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794baedba0480e1b882b606cd302d8c4f5701cabac7a0c7d4565fb7b3d98e54a0dec8b76f8c001a784a5689954ce0aedcc1bbe8d13095a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b8400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083063477825fc88609184e72a0008301e8488084543ffee680a00de0b9d4a0f0c23546d31f1f70db00d25cf6a7af79365b4e058e4a6a3b69527bc0c0850177ddbebe");

    NewBlockMessage newBlockMessage = new NewBlockMessage(ConfigHelper.CONFIG, payload);
    logger.trace("{}", newBlockMessage);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:9,代码来源:NewBlockMessageTest.java


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