Here you can find the source of fromHex(String hex)
Parameter | Description |
---|---|
hex | the hex string |
private static byte[] fromHex(String hex)
//package com.java2s; public class Main { /**/*from www . j ava 2s. c om*/ * Converts a string of hexadecimal characters into a byte array. * * @param hex * the hex string * @return the hex string decoded into a byte array */ private static byte[] fromHex(String hex) { byte[] binary = new byte[hex.length() / 2]; for (int i = 0; i < binary.length; i++) { binary[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16); } return binary; } }