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

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

Description

hex String To Bytes

License

Apache License

Declaration

public static byte[] hexStringToBytes(String s) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static byte[] hexStringToBytes(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  w ww .j a  va2s.c  o m

        return data;
    }
}

Related

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