I'm saving a group of files and want to verify if the file contents has changed. When I create the file I calculate a MD5 CheckSum with the following function.
Code: Select all
function hexDigest pvalue
local tRes
put md5Digest(pValue) into tMD5
get binaryDecode("H*",tMD5,tRes)
return tRes
end hexDigest
Now I also save the CheckSum in an array for later reference. To determine if the file has changed I use the following function.
Code: Select all
function validLocalStore pCheckSum
put getLocalStoreName( ) into tFileName
-- Open the Cach File
put URL( "file:" & tFileName ) into tDataInput
if tDataInput is Empty then
return "ERROR: File Empty"
end if
put line 1 of tDataInput into tStoredCheckSum
replace CR with Empty in tStoredCheckSum
replace LF with Empty in tStoredCheckSum
replace CR with Empty in pCheckSum
replace LF with Empty in pCheckSum
if tStoredCheckSum = pCheckSum then
return "VALID"
else
return "ERROR: CheckSum Does Not Match"
end if
end validLocalStore
Array CheckSum = a07dd580783edd56c26dd4555e2b4b95
File CheckSum = a07dd580783edd56c26dd4555e2b4b95
As far as I can tell they are IDENTICAL, but the IF statement always says that they are not the same.
When I change the put URL( "file:" & tFileName ) into tDataInput ---> put URL( "binfile:" & tFileName ) into tDataInput
The IF statement says that the two strings are the same.
There is something going on that I don't understand.
I thought it was the CRLF, but I have done a replace statement for each.
Any Ideas??????