Android Byte Array to Hex Convert hex2byte(byte[] b)

Here you can find the source of hex2byte(byte[] b)

Description

hexbyte

Declaration

private static byte[] hex2byte(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    private static byte[] hex2byte(byte[] b) {
        if ((b.length % 2) != 0)
            throw new IllegalArgumentException();
        byte[] b2 = new byte[b.length / 2];
        for (int n = 0; n < b.length; n += 2) {
            String item = new String(b, n, 2);
            b2[n / 2] = (byte) Integer.parseInt(item, 16);
        }//from w  ww. j a  v a2s. c om
        return b2;
    }
}

Related

  1. byte2hex(byte[] b)
  2. byteArrayToHexString(byte[] b)
  3. bytesToHexString(byte[] bytes)
  4. toHex(byte[] buf)
  5. toHex(byte[] data)
  6. toHexString(byte[] b)
  7. toHexString(byte[] buf, int offset, int length)