0,0 → 1,26 |
package ak.hostadmiral.util; |
|
public class BinUtils |
{ |
private static final char[] hexDigits = { |
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' |
}; |
|
/** |
* converts password bytes to hex string |
*/ |
public static String bytesToHex(byte[] bytes) |
{ |
char[] buffer = new char[bytes.length * 2]; |
|
for (int i = 0; i < bytes.length; i++) { |
int low = (int)( bytes[i] & 0x0f); |
int high = (int)((bytes[i] & 0xf0) >> 4); |
|
buffer[i * 2] = hexDigits[high]; |
buffer[i * 2 + 1] = hexDigits[low]; |
} |
|
return new String(buffer); |
} |
} |