I have this python code:
f = open('file.bin', 'rb')
b = f.read(2)
bytes = b[0x0:0x2] //this is b'\x10\x24', for example
f.close()
a = int.from_bytes(bytes, 'big') //returns 4132
I can't seem to figure out how to achieve the same thing in C#.
Did find this method:
public static int IntFromBigEndianBytes(byte[] data, int startIndex = 0)
{
return (data[startIndex] << 24) | (data[startIndex + 1] << 16) | (data[startIndex + 2] << 8) | data[startIndex + 3];
}
Trying that method always results in an IndexOutOfRangeException because my input bytes are less than 4. An insight to why this is happening, or otherwise any information would be appreciated.