19 package org.sleuthkit.autopsy.datamodel;
22 import java.util.Arrays;
23 import java.util.Formatter;
30 final private static char[]
hexArray =
"0123456789ABCDEF".toCharArray();
42 public static String
byteArrayToHex(byte[] array,
int length,
long arrayOffset, Font font) {
53 public static String
byteArrayToHex(byte[] array,
int length,
long arrayOffset) {
58 StringBuilder outputStringBuilder =
new StringBuilder();
61 for (
int curOffset = 0; curOffset < length; curOffset += 16) {
64 if (length - curOffset < 16) {
65 lineLen = length - curOffset;
70 outputStringBuilder.append(String.format(
"0x%08x: ", arrayOffset + curOffset));
74 for (
int i = 0; i < 16; i++) {
76 int v = array[curOffset + i] & 0xFF;
77 outputStringBuilder.append(hexArray[v >>> 4]);
78 outputStringBuilder.append(hexArray[v & 0x0F]);
81 outputStringBuilder.append(
" ");
86 outputStringBuilder.append(
" ");
88 outputStringBuilder.append(
" ");
91 outputStringBuilder.append(
" ");
97 outputStringBuilder.append(
" ");
102 outputStringBuilder.append(
" ");
105 String ascii =
new String(array, curOffset, lineLen, java.nio.charset.StandardCharsets.US_ASCII);
106 for (
int i = 0; i < 16; i++) {
108 if (i < ascii.length()) {
112 if (dec < 32 || dec > 126) {
116 outputStringBuilder.append(c);
119 outputStringBuilder.append(
"\n");
122 return outputStringBuilder.toString();
130 String[] binary =
new String[array.length];
132 for (
int i = 0; i < array.length; i++) {
133 binary[i] = Integer.toBinaryString(array[i]);
135 return Arrays.toString(binary);
static String byteArrayToHex(byte[] array, int length, long arrayOffset)
static String charArrayToByte(char[] array)
static String byteArrayToHex(byte[] array, int length, long arrayOffset, Font font)
final static char[] hexArray