I'm writing a program that has a certain specific type of input file. This input file contains information about the program that created it. The information is always at the same offset in the file and is always the same number of bytes (4), but I only want to allow files that were made by certain programs. An example would be:
4D 53 88 5C
That's one of the acceptable values, but there are multiple others I'd like to accept, and a lot more that I don't want to accept.
I'm having trouble wrapping my head around creating a list of byte arrays, though. What I want to do is read the value from the file as a byte array then use:
acceptList.Cont ains(byte[]);
if the value I read from the file is contained in the array it'll return true, else it'll return false.
Since I know the byte values of the acceptable program ids, is there a way I can put those byte arrays into the list?
I understand that an alternative would be comparing the int32 value of the 4 bytes, would that be a better option to try than comparing byte arrays?
4D 53 88 5C
That's one of the acceptable values, but there are multiple others I'd like to accept, and a lot more that I don't want to accept.
I'm having trouble wrapping my head around creating a list of byte arrays, though. What I want to do is read the value from the file as a byte array then use:
acceptList.Cont ains(byte[]);
if the value I read from the file is contained in the array it'll return true, else it'll return false.
Since I know the byte values of the acceptable program ids, is there a way I can put those byte arrays into the list?
I understand that an alternative would be comparing the int32 value of the 4 bytes, would that be a better option to try than comparing byte arrays?
Comment