List of usage examples for org.apache.commons.codec.binary Hex decodeHex
public static byte[] decodeHex(char[] data) throws IllegalArgumentException
From source file:com.tiempometa.thingmagic.UsbReader.java
public void write(TagReadData data, String hexString) throws ReaderException, DecoderException { Gen2.TagData epc = new Gen2.TagData(Hex.decodeHex(hexString.toCharArray())); Gen2.WriteTag tagop = new Gen2.WriteTag(epc); logger.debug("Requesting write EPC..."); TagData target = new TagData(data.getEPCMemData()); reader.executeTagOp(tagop, target);/* www. j ava2 s. co m*/ logger.debug("Wrote tag!"); }
From source file:codes.writeonce.maven.plugins.soy.CompileMojo.java
private boolean isChanged(byte[] sourceDigestBytes) throws NoSuchAlgorithmException, IOException, DecoderException { if (!jsOutputDirectory.exists()) { return true; }// w w w . j a v a 2s . c o m final Path statusFilePath = getStatusFilePath(); if (!Files.exists(statusFilePath)) { return true; } final byte[] targetDigestBytes = getGeneratedFilesDigest(); try (FileInputStream in = new FileInputStream(statusFilePath.toFile()); InputStreamReader inputStreamReader = new InputStreamReader(in); BufferedReader reader = new BufferedReader(inputStreamReader)) { return !Arrays.equals(sourceDigestBytes, Hex.decodeHex(reader.readLine().toCharArray())) || !Arrays.equals(targetDigestBytes, Hex.decodeHex(reader.readLine().toCharArray())); } }
From source file:libepg.epg.section.body.eventinformationtable.EventInformationTableRepeatingPartTest.java
@Test public void fail_tomestamp_ffff() throws DecoderException, InvocationTargetException { LOG.info("???null?????"); String data = "7f61e111115400ffffff00164d0d6a706e0835243e5d3e704a7300540201ffc10188"; EventInformationTableRepeatingPart instance = init(Hex.decodeHex(data.toCharArray())); Timestamp st = instance.getStart_time_Object(); assertEquals(1471402440000L, st.getTime()); Timestamp en = instance.getStop_Time_Object(); assertEquals(en, null);//from ww w .j ava 2s . c o m }
From source file:com.microsoft.sqlserver.jdbc.datatypes.SQLServerSpatialDatatypeTest.java
@Test public void testGeometryCollectionWkb() throws DecoderException { String geoWKT = "GEOMETRYCOLLECTION(POINT(3 3 1), LINESTRING(1 0, 0 1, -1 0), CIRCULARSTRING(1 3, 3 5, 4 7, 7 3, 1 3), POLYGON((0 0 2, 1 10 3, 1 0 4, 0 0 2), (0 0 2, 1 10 3, 1 0 4, 0 0 2), (0 0 2, 1 10 3, 1 0 4, 0 0 2)), MULTIPOINT((2 3), (7 8 9.5)), MULTILINESTRING((0 2, 1 1), (1 0, 1 1)), MULTIPOLYGON(((0 0, 0 3, 3 3, 3 0, 0 0), (1 1, 1 2, 2 1, 1 1)), ((9 9, 9 10, 10 9, 9 9))), COMPOUNDCURVE(CIRCULARSTRING(1 0 3, 0 1 3, 9 6 3, 8 7 3, -1 0 3), CIRCULARSTRING(-1 0 3, 7 9 3, -10 2 3), (-10 2 3, 77 77 77, 88 88 88, 2 6 4), (2 6 4, 3 3 6, 7 7 1)), CURVEPOLYGON((0 0, 0 0, 0 0, 0 0), COMPOUNDCURVE((0 -23.43778, 0 23.43778), CIRCULARSTRING(0 23.43778, -45 -23.43778, 0 -23.43778)), COMPOUNDCURVE((0 -23.43778, 7 7, 0 23.43778), CIRCULARSTRING(0 23.43778, 8 8, 8 8, -45 23.43778, -90 23.43778), (-90 23.43778, -90 -23.43778), CIRCULARSTRING(-90 -23.43778, -45 -23.43778, 0 -23.43778))), POLYGON((0 0 2, 1 10 3, 1 0 4, 0 0 2)))"; byte[] geomWKB = Hex.decodeHex( "0100000002014A00000000000000000008400000000000000840000000000000F03F00000000000000000000000000000000000000000000F03F000000000000F0BF0000000000000000000000000000F03F00000000000008400000000000000840000000000000144000000000000010400000000000001C400000000000001C400000000000000840000000000000F03F000000000000084000000000000000000000000000000000000000000000F03F0000000000002440000000000000F03F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F03F0000000000002440000000000000F03F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F03F0000000000002440000000000000F03F000000000000000000000000000000000000000000000000000000000000004000000000000008400000000000001C40000000000000204000000000000000000000000000000040000000000000F03F000000000000F03F000000000000F03F0000000000000000000000000000F03F000000000000F03F0000000000000000000000000000000000000000000000000000000000000840000000000000084000000000000008400000000000000840000000000000000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F00000000000000400000000000000040000000000000F03F000000000000F03F000000000000F03F00000000000022400000000000002240000000000000224000000000000024400000000000002440000000000000224000000000000022400000000000002240000000000000F03F00000000000000000000000000000000000000000000F03F0000000000002240000000000000184000000000000020400000000000001C40000000000000F0BF00000000000000000000000000001C40000000000000224000000000000024C00000000000000040000000000040534000000000004053400000000000005640000000000000564000000000000000400000000000001840000000000000084000000000000008400000000000001C400000000000001C40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C7D79E59127037C00000000000000000C7D79E591270374000000000008046C0C7D79E59127037C00000000000000000C7D79E59127037C00000000000000000C7D79E59127037C00000000000001C400000000000001C400000000000000000C7D79E5912703740000000000000204000000000000020400000000000002040000000000000204000000000008046C0C7D79E591270374000000000008056C0C7D79E591270374000000000008056C0C7D79E59127037C000000000008046C0C7D79E59127037C00000000000000000C7D79E59127037C000000000000000000000000000000000000000000000F03F0000000000002440000000000000F03F000000000000000000000000000000000000000000000000000000000000F03F000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000004000000000000008400000000000001040000000000000004000000000000000400000000000000840000000000000104000000000000000400000000000000040000000000000084000000000000010400000000000000040000000000000F8FF0000000000002340000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF00000000000008400000000000000840000000000000084000000000000008400000000000000840000000000000084000000000000008400000000000405340000000000000564000000000000010400000000000001840000000000000F03F000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF0000000000000040000000000000084000000000000010400000000000000040120000000100000000010100000002040000000109000000010D00000001110000000115000000011600000001170000000119000000011B00000001200000000124000000032800000001340000000338000000033C000000014600000011000000FFFFFFFF0000000007000000000000000001000000000100000002000000000200000008000000000300000003000000000600000004050000000600000001050000000700000001000000000800000005080000000800000002080000000900000002000000000A000000060B0000000A000000030B0000000C00000003000000000D00000009000000000E0000000A0000000011000000031000000003010302000002000203020003010203" .toCharArray());/* w w w . j ava 2s. c o m*/ byte[] geogWKB = Hex.decodeHex( "E610000002214A000000000000000000084000000000000008400000000000000000000000000000F03F000000000000F03F00000000000000000000000000000000000000000000F0BF0000000000000840000000000000F03F000000000000144000000000000008400000000000001C40000000000000104000000000000008400000000000001C400000000000000840000000000000F03F000000000000000000000000000000000000000000002440000000000000F03F0000000000000000000000000000F03F00000000000000000000000000000000000000000000000000000000000000000000000000002440000000000000F03F0000000000000000000000000000F03F00000000000000000000000000000000000000000000000000000000000000000000000000002440000000000000F03F0000000000000000000000000000F03F000000000000000000000000000000000000000000000840000000000000004000000000000020400000000000001C4000000000000000400000000000000000000000000000F03F000000000000F03F0000000000000000000000000000F03F000000000000F03F000000000000F03F0000000000000000000000000000000000000000000008400000000000000000000000000000084000000000000008400000000000000000000000000000084000000000000000000000000000000000000000000000F03F000000000000F03F0000000000000040000000000000F03F000000000000F03F0000000000000040000000000000F03F000000000000F03F000000000000224000000000000022400000000000002440000000000000224000000000000022400000000000002440000000000000224000000000000022400000000000000000000000000000F03F000000000000F03F0000000000000000000000000000184000000000000022400000000000001C4000000000000020400000000000000000000000000000F0BF00000000000022400000000000001C40000000000000004000000000000024C0000000000040534000000000004053400000000000005640000000000000564000000000000018400000000000000040000000000000084000000000000008400000000000001C400000000000001C4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C7D79E59127037C00000000000000000C7D79E59127037400000000000000000C7D79E59127037C000000000008046C0C7D79E59127037C00000000000000000C7D79E59127037C000000000000000000000000000001C400000000000001C40C7D79E591270374000000000000000000000000000002040000000000000204000000000000020400000000000002040C7D79E591270374000000000008046C0C7D79E591270374000000000008056C0C7D79E59127037C000000000008056C0C7D79E59127037C000000000008046C0C7D79E59127037C00000000000000000000000000000000000000000000000000000000000002440000000000000F03F0000000000000000000000000000F03F00000000000000000000000000000000000000000000F03F000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000004000000000000008400000000000001040000000000000004000000000000000400000000000000840000000000000104000000000000000400000000000000040000000000000084000000000000010400000000000000040000000000000F8FF0000000000002340000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF00000000000008400000000000000840000000000000084000000000000008400000000000000840000000000000084000000000000008400000000000405340000000000000564000000000000010400000000000001840000000000000F03F000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF0000000000000040000000000000084000000000000010400000000000000040120000000100000000010100000002040000000109000000010D00000001110000000115000000011600000001170000000119000000011B00000001200000000124000000032800000001340000000338000000033C000000014600000011000000FFFFFFFF0000000007000000000000000001000000000100000002000000000200000008000000000300000003000000000600000004050000000600000001050000000700000001000000000800000005080000000800000002080000000900000002000000000A000000060B0000000A000000030B0000000C00000003000000000D00000009000000000E0000000A0000000011000000031000000003010302000002000203020003010203" .toCharArray()); Geometry geomWKT = Geometry.deserialize(geomWKB); Geography geogWKT = Geography.deserialize(geogWKB); assertEquals(geomWKT.asTextZM(), geoWKT); assertEquals(geogWKT.asTextZM(), geoWKT); }
From source file:com.joemelsha.crypto.hash.KeccakTest.java
public KeccakTest(Class<T> type, int digestSizeBits, String... inputs) { this.type = type; this.digestSizeBits = digestSizeBits; for (int i = 0; i + 2 <= inputs.length;) { String input = inputs[i++].replaceAll("\\s+", "").toLowerCase(); if (input.startsWith("0x")) input = input.substring(2);//from w w w. j a v a 2s. c om String output = inputs[i++].replaceAll("\\s+", "").toLowerCase(); if (output.startsWith("0x")) output = output.substring(2); ByteBuffer[] tv; try { tv = new ByteBuffer[] { ByteBuffer.wrap(Hex.decodeHex(input.toCharArray())), ByteBuffer.wrap(Hex.decodeHex(output.toCharArray())) }; } catch (DecoderException x) { throw new RuntimeException(x); } testVectors.add(tv); } }
From source file:davmail.util.StringUtil.java
/** * Convert hex value to base64.//from w w w . ja v a 2 s . c o m * * @param value hex value * @return base64 value * @throws DecoderException on error */ public static String hexToBase64(String value) throws DecoderException { String base64Value = null; if (value != null) { base64Value = new String(Base64.encodeBase64(Hex.decodeHex(value.toCharArray()))); } return base64Value; }
From source file:cn.quickj.AbstractApplication.java
private void decryptQuickjLicense(String hex) throws Exception { KeyFactory keyFactory = KeyFactory.getInstance("RSA"); byte[] encrypted = Hex.decodeHex(hex.toCharArray()); byte[] keydata = new byte[128]; System.arraycopy(encrypted, 0, keydata, 0, 128); String key = new String(Hex.encodeHex(keydata)); PublicKey pubKey = keyFactory .generatePublic(new RSAPublicKeySpec(new BigInteger(key, 16), new BigInteger("10001", 16))); Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); cipher.init(Cipher.DECRYPT_MODE, pubKey); byte[] decrypted = new byte[encrypted.length]; int outputOffset = 0; for (int offset = 128; offset < encrypted.length;) { int inputLen = (encrypted.length - offset) > 128 ? 128 : (encrypted.length - offset); outputOffset += cipher.doFinal(encrypted, offset, inputLen, decrypted, outputOffset); offset += inputLen;// w ww . j av a 2s . c o m } String licenseInfo = new String(decrypted, 0, outputOffset - 16, "utf8"); String[] s = licenseInfo.split("\\|"); hosts = s[1].split(","); endDate = new SimpleDateFormat("yyyy-MM-dd").parse(s[2]); byte[] md5 = new byte[16]; System.arraycopy(decrypted, outputOffset - 16, md5, 0, 16); licensePath = new String(Hex.encodeHex(md5)); }
From source file:com.lightboxtechnologies.spectrum.ExtractDataMapper.java
protected void process_extent(FSDataInputStream file, FileSystem fs, Path outPath, Map<String, ?> map, Context context) throws IOException, InterruptedException { final String id = (String) map.get("id"); byte[] id_b = null; try {/* w w w .j ava2 s . c o m*/ id_b = Hex.decodeHex(id.toCharArray()); } catch (DecoderException e) { throw new RuntimeException(e); } final long fileSize = ((Number) map.get("size")).longValue(); StringBuilder sb = new StringBuilder("Extracting "); sb.append(id); sb.append(":"); sb.append((String) map.get("fp")); sb.append(" ("); sb.append(fileSize); sb.append(" bytes)"); LOG.info(sb.toString()); MD5Hash.reset(); final Map<String, Object> rec = fileSize > SIZE_THRESHOLD ? process_extent_large(file, fs, outPath, map, context) : process_extent_small(file, fileSize, map, context); // check if the md5 is known final byte[] md5 = hash_lookup_and_mark(rec, "md5"); // check if the sha1 is known final byte[] sha1 = hash_lookup_and_mark(rec, "sha1"); // write the entry to the file table EntryTbl.put(FsEntryPut.create(id_b, rec, HBaseTables.ENTRIES_COLFAM_B)); // write the md5 version of the key for the hash table OutKey.set(KeyUtils.makeEntryKey(md5, (byte) 0, id_b)); final KeyValue ovMD5 = new KeyValue(OutKey.get(), HBaseTables.HASH_COLFAM_B, ingest_col, timestamp, empty); context.write(OutKey, ovMD5); // write the sha1 version of the key for the hash table OutKey.set(KeyUtils.makeEntryKey(sha1, (byte) 1, id_b)); final KeyValue ovSHA1 = new KeyValue(OutKey.get(), HBaseTables.HASH_COLFAM_B, ingest_col, timestamp, empty); context.write(OutKey, ovSHA1); }
From source file:com.tecapro.inventory.common.util.StringUtil.java
public static String decodeHex(String s) { String ret = null;/*from w w w . j a va 2s.c om*/ char[] c = s.toCharArray(); try { byte[] b = Hex.decodeHex(c); ret = new String(b, "UTF-8"); } catch (DecoderException e) { ret = s; } catch (UnsupportedEncodingException e) { ret = s; } return ret; }
From source file:com.zimbra.cs.servlet.util.CsrfUtil.java
/** * * @param data/* w w w . jav a 2 s.c om*/ * @return * @throws AuthTokenException */ private static Map<?, ?> getAttrs(String data) throws AuthTokenException { try { String decoded = new String(Hex.decodeHex(data.toCharArray())); return BlobMetaData.decode(decoded); } catch (DecoderException e) { throw new AuthTokenException("decoding exception", e); } catch (BlobMetaDataEncodingException e) { throw new AuthTokenException("blob decoding exception", e); } }