public static String byteArraytoHex(byte[] bytes)
{
StringBuffer buffer= new StringBuffer();
byte b;
for (int y = 0, x = 0; y < bytes.length; ++y, ++x)
{
b = ((byte) (bytes[y] >> 4));
b = (byte)( b<0?(16+b):b);
buffer.append(Integer.toString((b), 16).toUpperCase());
b = ((byte) (bytes[y] & 0xF));
b=(byte)( b<0?(16+b):b);
buffer.append(Integer.toString((b), 16).toUpperCase());
buffer.append(" ");
}
return buffer.toString();
}
No comments:
Post a Comment