List of usage examples for org.apache.commons.codec.binary Hex decodeHex
public static byte[] decodeHex(char[] data) throws IllegalArgumentException
From source file:ezbake.services.graph.archive.TransactionIdGenerator.java
private static byte[] getUUID(String uuid) throws DecoderException { logger.info("Getting compressed UUID for " + uuid); Preconditions.checkNotNull(uuid);//from w w w. ja v a2 s . c om byte[] array = Hex.decodeHex(uuid.toCharArray()); byte[] result = new byte[6]; for (int i = 0; i < array.length; i++) { result[i % result.length] ^= array[i]; } return result; }
From source file:libepg.epg.section.sdt.descriptor.ServiceDescriptorTest.java
/** * Test of getService_name method, of class ServiceDescriptor. *//*from w w w . ja v a 2s .co m*/ @Test public void testGetService_name() throws DecoderException { LOG.debug("getService_name"); ServiceDescriptor instance = new ServiceDescriptor(sdesc); byte[] expResult = Hex.decodeHex("0e4e484b451d461d6c310f456c357e".toCharArray()); byte[] result = instance.getService_name(); assertArrayEquals(expResult, result); }
From source file:libepg.epg.section.servicedescriptiontable.descriptor.ServiceDescriptorTest.java
/** * Test of getService_name method, of class ServiceDescriptor. *///w w w . j ava 2s .c om @Test public void testGetService_name() throws DecoderException { LOG.info("getService_name"); ServiceDescriptor instance = new ServiceDescriptor(sdesc); byte[] expResult = Hex.decodeHex("0e4e484b451d461d6c310f456c357e".toCharArray()); byte[] result = instance.getService_name(); assertArrayEquals(expResult, result); }
From source file:libepg.epg.section.eit.descriptor.extendedeventdescriptor.ExtendedEventDescriptorItemTest.java
/** * Test of getData method, of class ExtendedEventDescriptorItem. *//*from www .j a va 2 s. co m*/ @Test public void testGetData() throws DecoderException { LOG.debug("getData"); ExtendedEventDescriptorItem instance = target; byte[] expResult = Hex.decodeHex( "084856414846624d46dc3c673f4d3878cf3f373f4d4c2132683248fe4c7045673877b5f3214a0e32360f214bfa42673358423436483865fd306c4559cf42673c6a0e49540f346b3648cb3d223f26b7bfacfd3b52c9e2ce3a22abe9ce4c34c0c3bf4c2132683248ce463bf2447ce1adecba0e330f472fc742603f26b7bffa48603d77ce1b7cc7d3e5f91972386532211b7db7b7bfceacfb0e5745420f4c213268fcce40243326fab3b33f74472fc70e5745421b6f5e732cce352448ac0f3c21213945503e6cb7fd4c2132683248cbcaeb1b6f41637339e20f392dacc3bffae8a6e4af3925adca" .toCharArray()); byte[] result = instance.getData(); assertArrayEquals(expResult, result); }
From source file:com.bitbreeds.webrtc.sctp.messaging.SCTPServiceTest.java
@Test public void solveInput() throws DecoderException { String input = "13881388548b3c9b4941db3e0a0000208f89999e04ebc3eb34da090dd11bd97422f5ff3600000154eeb897d8"; byte[] out = srv.handleRequest(Hex.decodeHex(input.toCharArray())).get(0); }
From source file:gobblin.metrics.reporter.util.SchemaRegistryVersionWriter.java
@Override public void writeSchemaVersioningInformation(Schema schema, DataOutputStream outputStream) throws IOException { String schemaId = this.schemaId.isPresent() ? this.schemaId.get() : this.getIdForSchema(schema); outputStream.writeByte(KafkaAvroSchemaRegistry.MAGIC_BYTE); try {/*from w w w . j ava 2 s . c o m*/ outputStream.write(Hex.decodeHex(schemaId.toCharArray())); } catch (DecoderException exception) { throw new IOException(exception); } }
From source file:libepg.epg.section.eventinformationtable.descriptor.extendedeventdescriptor.ExtendedEventDescriptorItemTest.java
/** * Test of getData method, of class ExtendedEventDescriptorItem. *///from www .j a v a 2s . c o m @Test public void testGetData() throws DecoderException { LOG.info("getData"); ExtendedEventDescriptorItem instance = target; byte[] expResult = Hex.decodeHex( "084856414846624d46dc3c673f4d3878cf3f373f4d4c2132683248fe4c7045673877b5f3214a0e32360f214bfa42673358423436483865fd306c4559cf42673c6a0e49540f346b3648cb3d223f26b7bfacfd3b52c9e2ce3a22abe9ce4c34c0c3bf4c2132683248ce463bf2447ce1adecba0e330f472fc742603f26b7bffa48603d77ce1b7cc7d3e5f91972386532211b7db7b7bfceacfb0e5745420f4c213268fcce40243326fab3b33f74472fc70e5745421b6f5e732cce352448ac0f3c21213945503e6cb7fd4c2132683248cbcaeb1b6f41637339e20f392dacc3bffae8a6e4af3925adca" .toCharArray()); byte[] result = instance.getData(); assertArrayEquals(expResult, result); }
From source file:io.stallion.utils.Encrypter.java
private static String doDecryptString(String password, String encryptedBase32) throws Exception { encryptedBase32 = StringUtils.strip(encryptedBase32, "="); String salt = encryptedBase32.substring(0, 16); String ivString = encryptedBase32.substring(16, 48); byte[] iv = new byte[0]; try {//from w ww. j a v a2 s. com iv = Hex.decodeHex(ivString.toCharArray()); } catch (DecoderException e) { throw new RuntimeException(e); } encryptedBase32 = encryptedBase32.substring(48); Base32 decoder = new Base32(); byte[] encrypted = decoder.decode(encryptedBase32.toUpperCase()); SecretKeySpec skeySpec = makeKeySpec(password, salt); /* Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(iv)); */ Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding"); cipher.init(Cipher.DECRYPT_MODE, skeySpec, new GCMParameterSpec(128, iv)); byte[] original = cipher.doFinal(encrypted); return new String(original, Charset.forName("UTF-8")); }
From source file:com.weblyzard.lib.string.nilsimsa.Nilsimsa.java
private static byte[] _getByteArray(String hexString) { try {/* w w w. j av a 2 s .co m*/ return Hex.decodeHex(hexString.toCharArray()); } catch (DecoderException e) { e.printStackTrace(); return null; } }
From source file:libepg.epg.util.datetime.DateTimeFieldConverterTest.java
/** * Test of BytesToSqlDateTime method, of class DateTimeFieldConverter. * * @throws java.lang.Exception/*from w w w . j a va 2s . c o m*/ */ @Test public void testBytesTOSqlDateTime1() throws Exception { LOG.info("BytesTOSqlDateTime1"); byte[] source = Hex.decodeHex("C079124500".toCharArray()); Timestamp expResult = new Timestamp( new java.text.SimpleDateFormat("yyyyMMddHHmmss").parse("19931013124500").getTime()); Timestamp result = DateTimeFieldConverter.BytesToSqlDateTime(source); assertEquals(expResult, result); }