2 * Copyright (C) 2014 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 package org
.strongswan
.android
.utils
;
21 static final char[] HEXDIGITS
= "0123456789abcdef".toCharArray();
24 * Converts the given byte array to a hexadecimal string encoding.
26 * @param bytes byte array to convert
29 public static String
bytesToHex(byte[] bytes
)
31 char[] hex
= new char[bytes
.length
* 2];
32 for (int i
= 0; i
< bytes
.length
; i
++)
35 hex
[i
*2] = HEXDIGITS
[(value
& 0xf0) >> 4];
36 hex
[i
*2+1] = HEXDIGITS
[ value
& 0x0f];
38 return new String(hex
);