Guest User

Untitled

a guest
Dec 14th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
  2. public static String bytesToHex(byte[] bytes) {
  3. char[] hexChars = new char[bytes.length * 2];
  4. for ( int j = 0; j < bytes.length; j++ ) {
  5. int v = bytes[j] & 0xFF;
  6. hexChars[j * 2] = hexArray[v >>> 4];
  7. hexChars[j * 2 + 1] = hexArray[v & 0x0F];
  8. }
  9. return new String(hexChars);
  10. }
Add Comment
Please, Sign In to add comment