Android Hex String to Byte Array Convert hexStringToByteArray(String s)

Here you can find the source of hexStringToByteArray(String s)

Description

hex String To Byte Array

License

Open Source License

Declaration

public static byte[] hexStringToByteArray(String s) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte[] hexStringToByteArray(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));
        }/*from  www .  j  a v  a  2 s  . c o  m*/

        return data;
    }
}

Related

  1. fromHex(String hex)
  2. hexToBytes(String str)
  3. hexToByte(String input)
  4. hexToBytes(String hexString)
  5. hexToByte(char char1, char char2)
  6. hexStringToBytes(String s)
  7. hex2bytes(String hex)
  8. hexStr2ByteArr(String paramString)
  9. hexStr2ByteArr(String str)