當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。