Skip to content

Instantly share code, notes, and snippets.

@yocontra
Created September 24, 2013 22:37
Show Gist options
  • Save yocontra/6692309 to your computer and use it in GitHub Desktop.
Save yocontra/6692309 to your computer and use it in GitHub Desktop.
pre-conversion
public static String byteArrayToHex(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
{
byte[] arrayOfByte = new byte[paramInt2];
for (int i = 0; ; i++)
{
if (i >= paramInt2)
return ByteUtility.bytesToHex(arrayOfByte);
arrayOfByte[i] = paramArrayOfByte[(i + paramInt1)];
}
}
public static int byteArrayToInt(byte[] paramArrayOfByte, int paramInt)
throws Exception
{
return (paramArrayOfByte[(paramInt + 0)] << 24) + ((0xFF & paramArrayOfByte[(paramInt + 1)]) << 16) + ((0xFF & paramArrayOfByte[(paramInt + 2)]) << 8) + (0xFF & paramArrayOfByte[(paramInt + 3)]);
}
public static int byteArrayToInt(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
{
int i = 0;
int j = 0;
if (j >= paramInt2)
return i;
if ((j == 0) && (paramArrayOfByte[(paramInt1 + (paramInt2 - 1) - j)] < 0))
i |= 0xFFFFFFFF & paramArrayOfByte[(paramInt1 + (paramInt2 - 1) - j)];
while (true)
{
if (j < paramInt2 - 1)
i <<= 8;
j++;
break;
i |= 0xFF & paramArrayOfByte[(paramInt1 + (paramInt2 - 1) - j)];
}
}
public static long byteArrayToLong(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
{
long l = 0L;
int i = 0;
if (i >= paramInt2)
return l;
if ((i == 0) && (paramArrayOfByte[(paramInt1 + (paramInt2 - 1) - i)] < 0));
for (l |= 0xFFFFFFFF & paramArrayOfByte[(paramInt1 + (paramInt2 - 1) - i)]; ; l |= 0xFF & paramArrayOfByte[(paramInt1 + (paramInt2 - 1) - i)])
{
if (i < paramInt2 - 1)
l <<= 8;
i++;
break;
}
}
public static String byteArrayToString(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
{
byte[] arrayOfByte = new byte[paramInt2];
for (int i = 0; ; i++)
{
if (i >= paramInt2)
return new String(arrayOfByte).trim();
arrayOfByte[i] = paramArrayOfByte[(i + paramInt1)];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment