List of usage examples for org.apache.commons.codec.binary Hex decodeHex
public static byte[] decodeHex(char[] data) throws IllegalArgumentException
From source file:libepg.epg.util.AribstrTest.java
/** * Test of AribToString method, of class Aribstr. * * @throws java.lang.Exception//from ww w .j a v a 2s . c o m */ @Test public void testAribToString() throws Exception { LOG.debug("AribToString"); byte[] pSrcData = Hex.decodeHex("0e4e484b451d461d6c310f456c357e".toCharArray()); String expResult = "?"; String result = Aribstr.AribToString(pSrcData); LOG.debug(result); assertEquals(expResult, result); }
From source file:com.google.u2f.gaedemo.servlets.RemoveTokenServlet.java
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { User user = userService.getCurrentUser(); String publicKey = req.getParameter("public_key"); try {//from w ww . j a va 2s . c o m u2fServer.removeSecurityKey(user.getUserId(), Hex.decodeHex(publicKey.toCharArray())); } catch (U2FException e) { throw new ServletException("couldn't remove U2F token", e); } catch (DecoderException e) { throw new ServletException("invalid public key", e); } JsonObject result = new JsonObject(); result.addProperty("status", "ok"); resp.setContentType("application/json"); resp.getWriter().println(result.toString()); }
From source file:libepg.epg.section.sdt.ServiceDescriptionTableRepeatingPartTest.java
public ServiceDescriptionTableRepeatingPartTest() throws DecoderException { x = Hex.decodeHex(testData.toCharArray()); }
From source file:architecture.common.BlowFishTest.java
@Test public void testBlowfish() throws Exception { String Key = "password"; byte[] KeyData = Key.getBytes(); SecretKeySpec KS = new SecretKeySpec(KeyData, "Blowfish"); Cipher cipher = Cipher.getInstance("Blowfish"); cipher.init(Cipher.ENCRYPT_MODE, KS); // encrypt message String inputText = "MyTextToEncrypt"; byte[] encrypted = cipher.doFinal(inputText.getBytes()); String encryptedString = Hex.encodeHexString(encrypted); System.out.println(" : " + encryptedString); cipher.init(Cipher.DECRYPT_MODE, KS); byte[] decrypt = cipher.doFinal(Hex.decodeHex(encryptedString.toCharArray())); System.out.println(" : " + new String(decrypt)); }
From source file:de.catma.serialization.tei.pointer.TextFragmentIdentifier.java
public byte[] getMd5HexValueAsBytes() throws DecoderException { return Hex.decodeHex(getMd5HexValue().toCharArray()); }
From source file:cl.whyem.testsutilityproject.otpgenerator.KeyBase.java
protected static byte[] dec(String val) { try {// ww w . j a v a 2 s . com return Hex.decodeHex(val.toCharArray()); } catch (Throwable t) { throw new RuntimeException(t); } }
From source file:com.blackcrowsys.sinscrypto.AesEncryptor.java
@Override public String encrypt(String secretkey, String iv, String toEncrypt) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, DecoderException { Cipher cipher = Cipher.getInstance(AESMODE); SecretKeySpec secretKeySpec = new SecretKeySpec(secretkey.getBytes(), AES); cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, new IvParameterSpec(Hex.decodeHex(iv.toCharArray()))); return Base64.encodeBase64String(cipher.doFinal(toEncrypt.getBytes())); }
From source file:libepg.common.packet.TsPacket_error.java
public TsPacket_error() throws DecoderException { this.target_transport_error_indicator_not_zero_01 = new TsPacket( Hex.decodeHex(p_transport_error_indicator_not_zero_01)); this.target_transport_error_indicator_not_zero_02 = new TsPacket( Hex.decodeHex(p_transport_error_indicator_not_zero_02)); }
From source file:SCTPChecksumTest.java
@Test public void testCsum() throws DecoderException { SCTPMessage message = SCTPMessage.fromBytes(Hex.decodeHex(data.toCharArray())); System.out.println(message); }
From source file:libepg.epg.section.SectionBodyTest.java
public SectionBodyTest() throws DecoderException, NoSuchMethodException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { data1 = Hex.decodeHex( "7fe1d100007fe1ff0408f30020481201000f0e4e484b451d461d6c310f456c357ec10184cf0701fe08f00104080409f3001c481201000f0e4e484b451d461d6c320f456c357ec10184cf0302fe08040af3001c481201000f0e4e484b451d461d6c330f456c357ec10184cf0302fe080588e5001f480ec0000b0e4e484b0f374842530e32c10188cf0a030e4e484b0f215d0e32" .toCharArray());/* ww w. j av a2 s . c om*/ data2 = Hex.decodeHex( "7fe0cd00007fe0ff0400f3002248140100110e4e484b0f416d39670e31fe0f456c357ec10184cf0701fe00f00004000401f3001e48140100110e4e484b0f416d39670e32fe0f456c357ec10184cf0302fe000580e500254814c000110e4e484b0f374842530e47fe0f456c357ec10188cf0a030e4e484b0f215d0e47" .toCharArray()); //?? this.testBody1 = SectionBodyTest.init(new Object[] { TABLE_ID.SDT, data1 }); this.testBody2 = SectionBodyTest.init(new Object[] { TABLE_ID.SDT, data2 }); }