VB.net Byte Array Search -


i in process of developing simple virus scanner, , searching speed improvements on following function:

public function findainb(byref bytearraya() byte, byref bytearrayb() byte) integer     dim startmatch integer = -1     dim offseta integer = 0     dim offsetb integer = 0      offsetb = 0 bytearrayb.length - 1         if bytearraya(offseta) = bytearrayb(offsetb)             if startmatch = -1 andalso offsetb < bytearrayb.length - 8                 startmatch = offsetb             end if             offseta += 1             if offseta = bytearraya.length                 exit             end if         else             offseta = 0             startmatch = -1         end if     next     return startmatch end function 

i need turbo fast because it's searching 7800 byte arrays in selected file's bytes. kind of hard explain there alternative code above or way speed up?

thanks in advance!

you should check out string search algorithms boyer-moore.

although you're not searching text, are searching strings of bytes within larger string of bytes, these type of algorithms out considerably.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -