Page 1 of 1

[Implemented] More flexible cipher lib commands please

Posted: Sun Mar 05, 2006 4:14 am
by va!n
It would be very nice to have the posiblity to do a CRC32 fingerprint directly on files (even on very big files instead reading the big files into memory)

In this case i would like to have an advanced version for such commands to define the start- and endpostion of a file. What dd you think about this?

CRC32FileFingerprint(filename$, [startpos, endpos])
MD5FileFingerprint(Filename$, [startpos, endpos])

Posted: Thu Apr 05, 2007 9:12 am
by nco2k
i second the request and an initial parameter would be also very usefull. as far as i can remember, fred said 4 years ago that he will implement this "soon". :cry:

Code: Select all

CRC32Fingerprint(Buffer, Length, Initial)
MD5Fingerprint(Buffer, Length, Initial)
c ya,
nco2k

Posted: Thu Apr 05, 2007 6:32 pm
by Fred
For the "Initial" stuff, it's like doing Buffer+Initial no ? Or I miss something obvious ?

Posted: Thu Apr 05, 2007 7:58 pm
by nco2k
i mean initial like in this code by horst:

Code: Select all

; ---------------------------------------------------------------
; CRC32 Calculation - supports handling file by chunks 
; Note: The CRC table is initialized at startup 
; by Horst Schaeffer - horst.schaeffer@gmx.net
; ---------------------------------------------------------------

;  Note: CRC of a file can be computed ..
;  (1) by reading the complete file into a memory buffer 
;      Parameters: *Memory,Size,0  (initial CRC = 0)
;  (2) by reading portions of the file: the CRC of the previous 
;      portion is always used as starting value for the next 
;      portion; initial CRC = 0
; ---------------------------------------------------------------
; initialize

*CRCtable  = AllocateMemory(1024)
*CRCpoint.long = *CRCtable
For index = 0 To 255 
  Value = index 
  For i = 1 To 8 
    LSB = Value & 1
    Value >> 1  & $7FFFFFFF
    If LSB : Value ! $EDB88320 : EndIf 
  Next 
  *CRCpoint\l = Value : *CRCpoint + 4
Next 

;  Compute CRC32 for data area given by *Memory pointer and Size,
;  and InitialCRC from last chunk (first time: 0) 
;  returns (new) CRC

Procedure CRC32compute(*Memory.byte,Size,InitialCRC)
  Shared *CRCtable 
  Protected CRC.l, *CRCpoint.long
  CRC = ~InitialCRC
  While Size 
    Value = ((CRC ! *Memory\b) & $FF) << 2
    CRC >> 8 & $00FFFFFF
    *CRCpoint = *CRCtable + Value 
    CRC ! *CRCpoint\l 
    *Memory +1 : Size -1 
  Wend  
ProcedureReturn ~CRC
EndProcedure 
so we could use the last crc32 chunk as starting value for the next chunk and so on.

c ya,
nco2k

Posted: Thu Apr 05, 2007 9:42 pm
by Fred
That makes sens.