Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compare 2 text files using checksum
Message
From
14/11/2009 18:35:05
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
14/11/2009 10:38:08
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01434733
Message ID:
01434788
Views:
61
>>>Hi all
>>>
>>>I can use FILETOSTR(), low level file access or FC.exe to compare 2 text files and know if they are same. I was curious if SYS(2007, FILETOSTR("MyFile.txt")) help me in this matter by comparing with a previously generated checksum value.
>>>
>>>My concern being small, say a single character, change to a big text file will guaranteed return a different checksum value?
>>>
>>>UPDATE, just thought this question. What are the chances that 2 different text files might return a same value?
>>>
>>>Please advise.
>>
>>This particular checksum gives 65,000 different values, and it is designed so that a change to a single byte will give a different result. Changes in several places in the document should give you a probability of about 1/65,000, or 0.0015%, of a collision.
>
>That's if you use sys(2007) the old 16 bit way - there's an additional parameter now, so it can do 32 bit. The odds of two strings yielding the same checksum are 1 against 2G (or 4G if it's an unsigned integer, which I guess it is).

Oh, OK, thanks. I had only checked the help for VFP 6, which I am still using for some projects. Probably time to upgrade.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform