I'm trying to understand some basics, I'm trying to read binary file using Java, in this case this is irrelevant, but might help with the approach, I think. So, I know that the first four bytes of the file have a value of 0x9AA2D903. But, when I read it they have "reversed" order, like that: 03 D9 A2 9A (03 - the first byte, D9 - the second and so on).
What I need to do in order to compare the value of 0x9AA2D903 and the output I'm getting? First, that comes in mind is to get an array of these 4 bytes, then flip them and convert to string. But it looks horrible.
If you could point to some literature, that would be great.
code:
Path path = Paths.get(Utils.getResourseURI("Demo.kdbx"));
try {
FileInputStream fin = new FileInputStream(path.toString());
}
int len;
byte bytes[] = new byte[16];
do {
len = fin.read(bytes);
for (int j = 0; j < len; j++)
System.out.printf("%02d\n", bytes[j]);
} while (len != -1);
}