md5 of big files.

BlitzMax Forums/BlitzMax Programming/md5 of big files.

You should be doing something like this (psuedo code)...
Function md5_file:String(FileName:String, bufferSize:Int=$400000)
  ...Set up MD5 constants, create bank and open file stream, etc...
   
  repeat
    fill buffer with data from file
    
    if EOF
      set upper data boundry to (number of bytes read this loop) mod (64 - 9) bytes
      write $80 after the last byte
      pad to (upper data boundry - 8) with null bytes
      write little endian long of total length of data in bits to (upper data boundry - 8)
    end if
      
    For Local chunkStart=0 Until (end of data in ints) Step 16
      ...MD5 passes getting data from the bank as little endian ints...	
    Next
  
  until EOF
	Return (LEHex(h0) + LEHex(h1) + LEHex(h2) + LEHex(h3)).ToLower()  
End Function