Question Best way to analyse bytes?

Cheetah

Well-known member
Joined
Oct 12, 2006
Messages
232
Programming Experience
Beginner
Hi there,

I have an array of bytes which its length in 12.

I need to analyse these bytes and have some logic run if a certain byte sequence occurs.

I only need to analyse bytes with indicies: 1,2 & 3 where byte(11) = 1 as the rest of the bytes are the same.

======

So how would you analyse it? I mean, if i was to do it I would probably add all the possible byte combinations to 3 lists at runtime (1 byte in each list). Then search the first list for the indicies with byte(1) in it, then out of the indexs return from the matches in the first list, search the second list and then do the same for the third so you end up with 1 index and you can use that in a switch statement to run that logic.

Hope that makes sense? Is there a faster way to do it with better performance/fewer cpu cycles needed?

Thanks.
 
Last edited:
If the individual bytes of these 3 doesn't doesn't have a meaning or compare purpose I'd add them together as a hex string (byt.ToString("x2")) and just compare this single string with the targets. For example bytes {1, 11, 111} would translate to the hex string "010b6f".
 
Back
Top