List of usage examples for org.apache.commons.codec.binary Hex decodeHex
public static byte[] decodeHex(char[] data) throws IllegalArgumentException
From source file:com.linkedin.databus2.producers.gg.GGEventGenerationFactory.java
public static byte[] stringToHex(String hexString) throws DecoderException { return Hex.decodeHex(hexString.toCharArray()); }
From source file:com.microsoft.sqlserver.jdbc.datatypes.SQLServerSpatialDatatypeTest.java
@Test public void testMultiPolygonWkb() throws DecoderException { String geoWKT = "MULTIPOLYGON(((1 1, 1 2, 2 1, 1 1), (0 0, 0 3, 3 3, 3 0, 0 0 7)), ((9 9, 9 10, 10 9, 9 9)))"; byte[] geomWKB = Hex.decodeHex( "0000000001010D000000000000000000F03F000000000000F03F000000000000F03F00000000000000400000000000000040000000000000F03F000000000000F03F000000000000F03F000000000000000000000000000000000000000000000000000000000000084000000000000008400000000000000840000000000000084000000000000000000000000000000000000000000000000000000000000022400000000000002240000000000000224000000000000024400000000000002440000000000000224000000000000022400000000000002240000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF0000000000001C40000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF0300000002000000000004000000020900000003000000FFFFFFFF0000000006000000000000000003000000000200000003" .toCharArray());// w w w . j a va 2s.com byte[] geogWKB = Hex.decodeHex( "E610000002010D000000000000000000F03F000000000000F03F0000000000000040000000000000F03F000000000000F03F0000000000000040000000000000F03F000000000000F03F000000000000000000000000000000000000000000000840000000000000000000000000000008400000000000000840000000000000000000000000000008400000000000000000000000000000000000000000000022400000000000002240000000000000244000000000000022400000000000002240000000000000244000000000000022400000000000002240000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF0000000000001C40000000000000F8FF000000000000F8FF000000000000F8FF000000000000F8FF0300000001000000000104000000010900000003000000FFFFFFFF0000000006000000000000000003000000000200000003" .toCharArray()); Geometry geomWKT = Geometry.deserialize(geomWKB); Geography geogWKT = Geography.deserialize(geogWKB); assertEquals(geomWKT.asTextZM(), geoWKT); assertEquals(geogWKT.asTextZM(), geoWKT); }
From source file:mitm.common.security.KeyEncoderTest.java
private static PublicKey decodePublicKey(String encoded) throws DecoderException, InvalidKeySpecException { byte[] rawKey = Hex.decodeHex(encoded.toCharArray()); KeySpec keySpec = new X509EncodedKeySpec(rawKey); return keyFactory.generatePublic(keySpec); }
From source file:libepg.epg.section.SectionTest.java
/** * Test of getData method, of class Section. *//* w w w . j av a 2 s . c om*/ @Test public void testGetSectionBody() throws DecoderException { LOG.debug("getSectionBody"); Section instance = this.testSection_OK; byte[] expResult = Hex.decodeHex( "7fe1d100007fe1ff0408f30020481201000f0e4e484b451d461d6c310f456c357ec10184cf0701fe08f00104080409f3001c481201000f0e4e484b451d461d6c320f456c357ec10184cf0302fe08040af3001c481201000f0e4e484b451d461d6c330f456c357ec10184cf0302fe080588e5001f480ec0000b0e4e484b0f374842530e32c10188cf0a030e4e484b0f215d0e32" .toCharArray()); byte[] result = instance.getSectionBody().getData(); assertArrayEquals(expResult, result); }
From source file:edu.wisc.doit.tcrypt.BouncyCastleFileDecrypter.java
protected CipherParameters getCipherParameters(TarArchiveInputStream inputStream) throws IOException, InvalidCipherTextException, DecoderException { final String keyFileStr = readAndDecrypt(inputStream, FileEncrypter.KEYFILE_ENC_NAME); //Split the keyfile final String[] keyFileParts = KEYFILE_SEPERATOR_PATTERN.split(keyFileStr); if (keyFileParts.length != 2) { throw new IllegalArgumentException(FileEncrypter.KEYFILE_ENC_NAME + " must have exactly two lines, this one has: " + keyFileParts.length); }/*from w w w. ja v a 2s.co m*/ //line 0 is the secretKey, 1 is the initVector, 2 is the file md5 final byte[] secretKey = Hex.decodeHex(keyFileParts[0].toCharArray()); final byte[] initVector = Hex.decodeHex(keyFileParts[1].toCharArray()); //Create the key parameters final KeyParameter keyParam = new KeyParameter(secretKey); return new ParametersWithIV(keyParam, initVector); }
From source file:libepg.ts.packet.TSpacketTest.java
/** * Test of equals method, of class TsPacket. *///from w w w. j av a 2 s. c o m @Test public void testEquals_Notsame() throws DecoderException { LOG.debug("equals_Notsame"); EqualsChecker<TsPacket> ec = new EqualsChecker<>(); TsPacket obj = new TsPacket(Hex.decodeHex(this.pd.p10)); TsPacket obj2 = new TsPacket(Hex.decodeHex(this.pd.p11)); TsPacket instance = this.target00; assertTrue(ec.check_not_same(instance, obj, obj2)); }
From source file:libepg.epg.section.sdt.ServiceDescriptionTableBodyTest.java
/** * Test of getRepeatingPart method, of class ServiceDescriptionTableBody. *//*from www.jav a2 s . c om*/ @Test public void testGetSDTBody() throws DecoderException { LOG.debug("getSDTBody"); ServiceDescriptionTableBody instance = this.sdth; byte[] expResult = Hex.decodeHex( "0408f30020481201000f0e4e484b451d461d6c310f456c357ec10184cf0701fe08f00104080409f3001c481201000f0e4e484b451d461d6c320f456c357ec10184cf0302fe08040af3001c481201000f0e4e484b451d461d6c330f456c357ec10184cf0302fe080588e5001f480ec0000b0e4e484b0f374842530e32c10188cf0a030e4e484b0f215d0e32" .toCharArray()); byte[] result = instance.getRepeatingPart(); assertArrayEquals(expResult, result); }
From source file:libepg.epg.section.servicedescriptiontable.ServiceDescriptionTableBodyTest.java
/** * Test of getRepeatingPart method, of class ServiceDescriptionTableBody. *///from w w w. j a v a2s. c o m @Test public void testGetSDTBody() throws DecoderException { LOG.info("getSDTBody"); ServiceDescriptionTableBody instance = this.sdth; byte[] expResult = Hex.decodeHex( "0408f30020481201000f0e4e484b451d461d6c310f456c357ec10184cf0701fe08f00104080409f3001c481201000f0e4e484b451d461d6c320f456c357ec10184cf0302fe08040af3001c481201000f0e4e484b451d461d6c330f456c357ec10184cf0302fe080588e5001f480ec0000b0e4e484b0f374842530e32c10188cf0a030e4e484b0f215d0e32" .toCharArray()); byte[] result = instance.getRepeatingPart(); assertArrayEquals(expResult, result); }
From source file:kr.debop4j.core.tools.StringTool.java
/** * 16 ? ?? ? .//from w ww .jav a2s . c o m * * @param hexString 16 ? ? * @return 16 ? */ public static byte[] getBytesFromHexString(final String hexString) { if (isEmpty(hexString)) return new byte[0]; try { return Hex.decodeHex(hexString.toCharArray()); } catch (DecoderException e) { log.error("16 ? ?? ? ? .", e); throw new RuntimeException(e); } }
From source file:libepg.epg.section.sdt.ServiceDescriptionTableRepeatingPartTest.java
/** * Test of equals method, of class TsPacket. *//*from www. j a v a 2 s .c o m*/ @Test public void testEquals_Notsame() throws DecoderException, Throwable { LOG.debug("equals_Notsame"); EqualsChecker<ServiceDescriptionTableRepeatingPart> ec = new EqualsChecker<>(); ServiceDescriptionTableRepeatingPart obj = ClassGetter.init(this.x); ServiceDescriptionTableRepeatingPart obj2 = ClassGetter.init(this.x); ServiceDescriptionTableRepeatingPart instance = ClassGetter.init( Hex.decodeHex("0409f3001c481201000f0e4e484b451d461d6c320f456c357ec10184cf0302fe08".toCharArray())); assertTrue(ec.check_not_same(instance, obj, obj2)); }