Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Generating a Checksum32 on a File
Message
De
29/11/1999 14:48:52
 
 
À
29/11/1999 07:40:34
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00296267
Message ID:
00296513
Vues:
22
>>PKZip has a nice feature that generates a 32-bit checksum of each file in the archive, in order to ensure data integrity.
>>
>>Can anyone outline how to generate one in VFP for an arbitrary file, or point me to a reference?
>
>You could use SYS(2007) after using FILETOSTR() to grab the file content; it is not the same checksum algorithm, yielding a 16 bit value, but it's free and quick:
>
>nCheckSum = SYS(2007,FILETOSTR(cFileToCheckSum))

Thanks for pointing out the breadth and depth of VFP! I never dreamed a database language would include such a low-level function.

OTOH I'm using VFP5, with no FILETOSTR(); I guess I'll have to set up a temporary cursor with a binary memo field, and run SYS(2007) against that.

A 16-bit checksum might be good enough for my purpose; if I understand it correctly, another nonidentical file will have the same 16-bit checksum on average only once every 2^16, or 65536 times.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform