Skip to content

Instantly share code, notes, and snippets.

@yuanliwei
Created December 10, 2015 06:52
Show Gist options
  • Save yuanliwei/8284e72bcdd7763a1a15 to your computer and use it in GitHub Desktop.
Save yuanliwei/8284e72bcdd7763a1a15 to your computer and use it in GitHub Desktop.
java code : byte[] -> Hex String
    public static String bytesToHexString(byte[] bytes) {
        StringBuffer sb = new StringBuffer();
        for (byte b : bytes) {
            int val = b & 0xff;
            if (val < 0x10) {
                sb.append("0");
            }
            sb.append(Integer.toHexString(val));
        }
        return sb.toString();
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment