1 | public static String bytesToHex(byte[] bytes) {
|
2 | return bytesToHex(bytes, 0, bytes.length); |
3 | } |
4 | |
5 | public static String bytesToHex(byte[] bytes, int ofs, int len) {
|
6 | StringBuilder stringBuilder = new StringBuilder(len*2); |
7 | for (int i = 0; i < len; i++) {
|
8 | String s = "0" + Integer.toHexString(bytes[ofs+i]); |
9 | stringBuilder.append(s.substring(s.length()-2, s.length())); |
10 | } |
11 | return stringBuilder.toString(); |
12 | } |
Snippet is not live.
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #2000460 |
| Snippet name: | bytesToHex (standard function) |
| Eternal ID of this version: | #2000460/1 |
| Text MD5: | 28e24d45a3bae75a71ae7f8f605a2dda |
| Author: | stefan |
| Category: | |
| Type: | New Tinybrain snippet |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-07-26 18:51:07 |
| Source code size: | 450 bytes / 12 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 1231 / 6077 |
| Referenced in: | [show references] |