Small remark for future optimization: this would be more efficient using some iterator. The way you do it now, there is one multiplication happening on each access, whereas an iterator just needs to add to the current position. This applies even if you do a byte-wise comparison (with the bit-wise access, there are even more operations needed to get the result).