Here you can find the source of fromHex(String s)
Parameter | Description |
---|---|
s | hex string |
static byte[] fromHex(String s)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w w w .j a va 2s . c o m*/ * Converts a hex string representation of bytes into a byte array * @param s hex string * @return byte array */ static byte[] fromHex(String s) { int len = s.length(); byte[] data = new byte[len / 2]; for (int i = 0; i < len; i += 2) { data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16)); } return data; } }