Return to Snippet

Revision: 25914
at June 17, 2010 18:09 by alejandrosuch


Updated Code
public static String getHexString(byte[] b) throws Exception {
  String result = "";
  for (int i=0; i < b.length; i++) {
    result += Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 );
  }
  return result;
}

public static byte[] getByteArray(String hexString) {
  return BigInteger(hexString,16).toByteArray(); 
}

Revision: 25913
at April 14, 2010 02:22 by alejandrosuch


Initial Code
public static String getHexString(byte[] b) throws Exception {
	  String result = "";
	  for (int i=0; i < b.length; i++) {
	    result +=
	          Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 );
	  }
	  return result;
	}

Initial URL

                                

Initial Description

                                

Initial Title
Convert byte array to Hex String and vice versa

Initial Tags

                                

Initial Language
Java