md5 of big files.

BlitzMax Forums/BlitzMax Programming/md5 of big files.

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I had this to hand...
Strict

Local start:Int = MilliSecs()

Print

Print Hex$(CRCFile("C:\Downloads\other\far_cry_v1.3.exe"))

Print (MilliSecs() - start)

'FlushMem

End

'Adaptation of MrCredo's CRC code
Function CRCFile(FileName:String, bufferSize:Int=$400000) 'default bufferSize = 4MB
  Local crc:Int = $FFFFFFFF , fileStream:TStream
  Global CRCTable:Int[]
  
  If CRCTable = Null
    Local i:Int, j:Int, value:Int
    
    CRCTable = New Int[256]
  
    For i=0 To 255
      value = i
      For j=0 To 7
        If value & $1 
          value = (value Shr 1) ~ $EDB88320
        Else
          value = value Shr 1
        EndIf
      Next
      CRCTable[i] = value
    Next
  EndIf
  
  fileStream = ReadStream(fileName$)
  If fileStream = Null Then Return
  
  Local buffer:TBank = CreateBank(bufferSize)
  Local bankPtr:Byte Ptr = buffer.Buf()
  
  Repeat
    Local bytesRead:Int = ReadBank(buffer, fileStream, 0, bufferSize)
    
    For Local b=0 Until bytesRead
      crc = (crc Shr 8) ~ CRCTable[bankPtr[b] ~ (crc & $FF)]
    Next
  Until Eof(FileStream)
  
  CloseStream FileStream
  
  Return ~crc
End Function
Should give you a reasonable idea of how you could go about it.