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


Java Hex.decodeHex方法代码示例

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


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

示例1: hexDecode

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
/**
 * Hex decode string.
 *
 * @param data the data
 * @return the string
 */
public static String hexDecode(final char[] data) {
    try {
        final byte[] result = Hex.decodeHex(data);
        return new String(result);
    } catch (final Exception e) {
        return null;
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:15,代码来源:EncodingUtils.java

示例2: decodeHash

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
public byte[] decodeHash(String encodedHash)
{
    if (!getEncodeHashAsBase64())
    {
        try
        {
            return Hex.decodeHex(encodedHash.toCharArray());
        }
        catch (DecoderException e)
        {
           throw new RuntimeException("Unable to decode password hash");
        }
    }
    else
    {
        return Base64.decodeBase64(encodedHash.getBytes());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:MD4PasswordEncoderImpl.java

示例3: compareChecksums

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
/**
 * Compare checksums from both files.
 * 
 * @param cipherFile
 *            Cipher file to test.
 * @param digestKey
 *            Key for decipher the checksum from cipher file.
 * @param plainFile
 *            Plain file to test.
 * @return
 */
private boolean compareChecksums(File cipherFile, String digestKey, File plainFile) {
	boolean checksumFail = true;
	try {
		String checksumOriginCiphered = searchValueInFile(cipherFile, "digest");
		SecretKeySpec saltAsKey = new SecretKeySpec(Hex.decodeHex(digestKey.toCharArray()), "AES");
		byte[] checksumOriginPlain = decipherText(Base64.decodeBase64(checksumOriginCiphered), saltAsKey);
		byte[] calculatedPlainChecksum = getChecksum(plainFile);
		for (int checksumIndex = 0; checksumIndex < checksumOriginPlain.length; checksumIndex++) {
			if (checksumOriginPlain[checksumIndex] != calculatedPlainChecksum[checksumIndex]) {
				checksumFail = false;
				break;
			}
		}
	} catch (IOException | GeneralSecurityException | DecoderException e) {
		e.printStackTrace();
	}
	return !checksumFail;
}
 
开发者ID:Mikiya83,项目名称:hbs_decipher,代码行数:30,代码来源:QNAPFileDecrypterEngine.java

示例4: test_call_setN

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
@Test
public void test_call_setN() throws Exception {
    final String contractByteCode = "6060604052341561000f57600080fd5b60d88061001d6000396000f3006060604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633e9552251460535780633f7a0270146079575b6001600081905550005b3415605d57600080fd5b60636099565b6040518082815260200191505060405180910390f35b3415608357600080fd5b6097600480803590602001909190505060a2565b005b60008054905090565b80600081905550505600a165627a7a72305820698e2e766377b7dd448267574b445559f53629f7435ffdcd3a8962ac98201b690029";

    /* setN(99) */
    EVMEnvironment evmEnvironment = new EVMEnvironment.EVMEnvironmentBuilder()
            .setCallData(Hex.decodeHex("3f7a02700000000000000000000000000000000000000000000000000000000000000063"))
            .build();
    EVMState state = runContract(contractByteCode, evmEnvironment);
    EVMStack stack = state.getStack();
    EVMStorage storage = state.getStorage();

    Assert.assertEquals(1, stack.size());
    Assert.assertTrue(Arrays.equals(
            Hex.decodeHex("3f7a0270"),
            stack.pop().getBytes()));
    TraceableWord expected = new TraceableWord(Hex.decodeHex("0000000000000000000000000000000000000000000000000000000000000063"), null);
    TraceableWord key = new TraceableWord(Hex.decodeHex("00"), null);
    TraceableWord storageContent = storage.get(key);
    Assert.assertTrue(Arrays.equals(expected.getBytes(), storageContent.getBytes()));
}
 
开发者ID:fergarrui,项目名称:ethereum-bytecode-analyzer,代码行数:22,代码来源:TestSimpleContract.java

示例5: decodeHex

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
/**
 * Hex解码.
 */
public static byte[] decodeHex(String input) {
	try {
		return Hex.decodeHex(input.toCharArray());
	} catch (DecoderException e) {
		throw uKettleException.unchecked(e);
	}
}
 
开发者ID:jiangzongyao,项目名称:kettle_support_kettle8.0,代码行数:11,代码来源:Encode.java

示例6: getPacket

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
public MAVLinkPacket getPacket() throws DecoderException {
    Parser parser = new Parser();
    MAVLinkPacket packet = null;

    for (byte b : Hex.decodeHex(data.toCharArray())) {
        packet = parser.mavlink_parse_char(b & 0xFF);
    }

    return packet;
}
 
开发者ID:envirover,项目名称:SPLGroundControl,代码行数:11,代码来源:RockBlockHttpHandler.java

示例7: verify

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
@Override
public void verify(DecodedJWT jwt, EncodeType encodeType) throws Exception {
    byte[] contentBytes = String.format("%s.%s", jwt.getHeader(), jwt.getPayload()).getBytes(StandardCharsets.UTF_8);
    byte[] signatureBytes = null;
    String signature = jwt.getSignature();
    String urlDecoded = null;
    switch (encodeType) {
        case Base16:
            urlDecoded = URLDecoder.decode(signature, "UTF-8");
            signatureBytes = Hex.decodeHex(urlDecoded);
            break;
        case Base32:
            Base32 base32 = new Base32();
            urlDecoded = URLDecoder.decode(signature, "UTF-8");
            signatureBytes = base32.decode(urlDecoded);
            break;
        case Base64:
            signatureBytes = Base64.decodeBase64(signature);
            break;
    }

    try {
        RSAPublicKey publicKey = keyProvider.getPublicKeyById(jwt.getKeyId());
        if (publicKey == null) {
            throw new IllegalStateException("The given Public Key is null.");
        }
        boolean valid = crypto.verifySignatureFor(getDescription(), publicKey, contentBytes, signatureBytes);
        if (!valid) {
            throw new SignatureVerificationException(this);
        }
    } catch (NoSuchAlgorithmException | SignatureException | InvalidKeyException | IllegalStateException e) {
        throw new SignatureVerificationException(this, e);
    }
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:35,代码来源:RSAAlgorithm.java

示例8: encodeHexAsBase64

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
public static String encodeHexAsBase64(String key) {
    requireNonNull(key, "`key` must not be null");
    requireNonNull(MoreHex.isHex(key), "`key` must be in hex");

    try {
        byte[] keyBase16 = Hex.decodeHex(key.toCharArray());
        return Base64.getEncoder().encodeToString(keyBase16);
    } catch (DecoderException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:12,代码来源:MoreBase64.java

示例9: main

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
public static void main(String[] args) throws DecoderException {

		// String hexString = "5095";
		String hexString = "789c6d8d4d4f83401884ff0b578c5dba0bbb98782015b1a1f8059a7222743fc8da96aecbdbdad6f8dfa5046fce6de6c9cc7c3bc522bfeec4baaa8dd1c2b9713c822e0a7ddfb91aa03c1a6d65552b90b6e794d2a0e7231c5a550d15b6ff96416fe590e38051c2281d732d640b5ae96172ea051c29be524c62e463e57382e854a08020a578c8febe38dfed5ba8e0642e9b98e21174bae97d16bfcde633299e0f49c81f27a26490b97665d7675dd0fdc35df1de994d23bc4301db349fbb918ea3e36b509878f7956d84dbb44b4ed23287b454f7119c12fea4968b64927d7c962179b9757e7e01ed1059d9";

		byte[] test = Hex.decodeHex(hexString.toCharArray());
		byte[] compressBytes = base64EncodeUrl(test);
		System.out.println("compress : " + new String(compressBytes));
		byte[] uncompressBytes = base64DecodeUrl(compressBytes);
		System.out.println("uncompress: "
				+ Hex.encodeHexString(uncompressBytes));
	}
 
开发者ID:51wakeup,项目名称:wakeup-qcloud-sdk,代码行数:13,代码来源:Base64Url.java

示例10: hexStringToByte

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
/**
 * Transform an hexadecimal String to a byte array.
 */
public static byte[] hexStringToByte(String hexString) {
    try {
        return Hex.decodeHex(hexString.toCharArray());
    } catch (DecoderException e) {
        throw new UnexpectedException(e);
    }
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:11,代码来源:CodeKit.java

示例11: decodeHex

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
/**
 * Hex解码.
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        throw new RRException("Hex解码出错");
    }
}
 
开发者ID:guolf,项目名称:pds,代码行数:11,代码来源:Encodes.java

示例12: while

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
private static SecretKeySpec bй0439йй0439й(String str) throws Exception {
    String str2 = null;
    while (true) {
        try {
            str2.length();
        } catch (Exception e) {
            b0429Щ0429Щ0429Щ = b0429ЩЩЩ0429Щ();
            try {
                return new SecretKeySpec(Hex.decodeHex(str.toCharArray()), "AES");
            } catch (Exception e2) {
                throw e2;
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:16,代码来源:rrrccc.java

示例13: decodeHex

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
/**
 * Hex解码.
 */
public static byte[] decodeHex(String input) {
    try {
        return Hex.decodeHex(input.toCharArray());
    } catch (DecoderException e) {
        throw Exceptions.unchecked(e);
    }
}
 
开发者ID:wolfboys,项目名称:opencron,代码行数:11,代码来源:Encodes.java

示例14: test_call_getN

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
@Test
public void test_call_getN() throws Exception {
    final String contractByteCode = "6060604052341561000f57600080fd5b60d88061001d6000396000f3006060604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633e9552251460535780633f7a0270146079575b6001600081905550005b3415605d57600080fd5b60636099565b6040518082815260200191505060405180910390f35b3415608357600080fd5b6097600480803590602001909190505060a2565b005b60008054905090565b80600081905550505600a165627a7a72305820698e2e766377b7dd448267574b445559f53629f7435ffdcd3a8962ac98201b690029";

    /* getN() */
    EVMEnvironment evmEnvironment = new EVMEnvironment.EVMEnvironmentBuilder()
            .setCallData(Hex.decodeHex("3e9552250000000000000000000000000000000000000000000000000000000000000063"))
            .build();
    EVMState state = runContract(contractByteCode, evmEnvironment);
    EVMStack stack = state.getStack();
    EVMStorage storage = state.getStorage();
    Assert.assertEquals(3, stack.size());

    Assert.assertTrue(Arrays.equals(
            Hex.decodeHex("60"),
            stack.pop().getBytes()));

    Assert.assertTrue(Arrays.equals(
            Hex.decodeHex("20"),
            stack.pop().getBytes()));

    Assert.assertTrue(Arrays.equals(
            Hex.decodeHex("3e955225"),
            stack.pop().getBytes()));

    TraceableWord key = new TraceableWord(Hex.decodeHex("00"), null);
    TraceableWord storageContent = storage.get(key);
    Assert.assertTrue(storageContent == null);
}
 
开发者ID:fergarrui,项目名称:ethereum-bytecode-analyzer,代码行数:30,代码来源:TestSimpleContract.java

示例15: data

import org.apache.commons.codec.binary.Hex; //导入方法依赖的package包/类
@Parameters(name = "key: {0} - tweak: {1} - radix: {2} - input: {3} - encrypted: {4}")
public static Object[][] data() throws DecoderException {
    final byte[] csrcKey = Hex.decodeHex("2b7e151628aed2a6abf7158809cf4f3c".toCharArray());
    return new Object[][]{
        // testing different key/tweak combinations
        {new byte[16], "00000000", 2, "00000000", "10010100"},
        {"q9yml3s5x4ds0f11".getBytes(), "FOOBAR", 36, "4D5D8GT15V1F58R5FP50", "R31MQ2D6538HT3087ISW"},
        {"0000000000000000".getBytes(), "}|>>[email protected])FOOBAZ:{#%^?", 20, "12FF9800", "00E45IC2"},
        {"0000000000065536".getBytes(), "4294967295", 10, "2147483647", "9115462938"},
        {"0000000000065536".getBytes(), "1231231231", 10, "2147483647", "9764557830"},

        // CSRC AES-FFX test vectors, in order, taken from http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/ffx/aes-ffx-vectors.txt
        {csrcKey, "9876543210", 10, "0123456789", "6124200773"},
        {csrcKey, "", 10, "0123456789", "2433477484"},
        {csrcKey, "2718281828", 10, "314159", "535005"},
        {csrcKey, "7777777", 10, "999999999", "658229573"},
        {csrcKey, "TQF9J5QDAGSCSPB1", 36, "C4XPWULBM3M863JH", "C8AQ3U846ZWH6QZP"},

        // testing the smallest message size
        {csrcKey, "", 36, "pp", "ka"},
        {csrcKey, "", 10, "00", "68"},

        // testing large message sizes which trigger the padding function
        {csrcKey, "", 10, "999999999999999999999999999999999999999999999999999999999", "688163234659466867211819888439067584894842543433045957530"},
        {csrcKey, "", 36, "z02zx56erbt89y4y4pl1j0df0we56ef8yu1g15f1002r5r58y4y11f0d0", "5TTL8KYK63BGZL0GCCTSLM7HPTOPFQ33EUIGSSPWHFLH13VSO5VGAFUV8"},
        {csrcKey, "", 34, "xxxxxxxxxxxxxxxxxxxxbase36charactersoratleastalmostxxxxxxxxxxxxxxxxxxxx", "MLM6T6UUXHNB0FCJCTBLSDXFM676GOCPH7KIPHEABS2LEWEUCSAMRCGDQTF2A448MR9BU6D"},
        {csrcKey, "", 36, "X6WDO10DKNC0PI034VXBOGH0STQVN37VR7TAVIRYMY2KVR19NWJ45DR2DA9VN8JOFM16EVG4M7Y3206O916HQO0RXM0AWY1KURTHA7RL1IL73Q613ABKI2IGON9LUKXNAUFVX7FHBD6CCMDSMZ0VUKJXODGTGY1Y0NJ66ASNWPL9BWTWUKFJTMQJCI8CFR7REZ4Y3F3LJES7YSS2WCA6J6AKPYXP31JW4NYVPCPDRJBDYPQPC5R820LYUSAB896CY728II73DN47GKK4NVE8ABCFUK5NESDY78WX8TJYRU2N9ZJXZRAIUXTLZ4Z1JRKFO474H0IEB3BYZQWVQA5P4NUA269FBU3RWZU0WH62BA7R5V5ZIH46ZQGN6BDXVU46P4VHKJLDS7UNVREEDR7EZVCSSSKZPD2MVURM5P2OCZID6M5IIMRQC3235NRJ38ZWO7KMVZTCTGWDNL4OMMPQMYDOI0UH5NDTFI1DR81C9M6FS3T6I6VG",
            "V45HF9QP2LQMZ17OA6FMQEO8GIUTXWV8WWTLYP3INXLNFUGNGYTRBX8G8QD2MOR00DW0V9Z5HUT13X1VQNMYG0M0J4M7NPASF16ZMH7617JEI3QUF9F9M5K4A1WJKE516M4Q1I74WYMS4W3KWUMRAQD6PLVIWS4230F0QGZ2KTAKY95R9EGQDE0TO18U715JIT9R5ZM3N67MFZH3C0V0BVJ2TAITBA0M2TQR2WP1R36YG3G7JJT8VV55NTP861GTWWMXRN43FZQHKC0CW9S7KY3QX3J7QX1MR1ON1M58N111NOE11BXYNQBJPP7B2O99OJ8CUF9WPIX6SFVWAQKUFBC8UI5IRRSUU6GGZ0RCDPNWXD1OLK0GMZ7IJW13FIV2DR7KR3E3NRRTUYVM4UDQ7Q1PWUUG1SKMBC17BAYG3OSZVSWUKXOJM7GYHYUHC0VAAJJ1VT5YHR1QCWLMRX8CWWCG3B7VK22BTOKG0NI4OX8I7MDJMLJS"}
    };
}
 
开发者ID:NCSC-NL,项目名称:PEF,代码行数:31,代码来源:TestFFXSpecificVectors.java


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