Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Encrypting a table field
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00315680
Message ID:
00317020
Vues:
70
>What exactly is the check sum value? How is it getting it? The size of the file and the information inside it does not seem to change the value.\
>
>Ron
>
>>>>What Barbara said. What I do is include the Sys[2007, expr] function and convert the return value to a number [integer], do some additional math add some number, square it, subtract a number, etc...

I loop through all fields, and convert the data to a string. I then get the check sum of that value and store it in the CHKSUM field for each record in the table.

I use this to detect any unauthorized editing of data outside my application. I only use this in my users table where I have set up their access rights [insert, update delete]. If I detect any data changes, the new check sum of the data will be different than that stored in that user's record. If no match, they are dropped to read only and possibly kicked out of the app. I get an e-mail notice [courtesy of WWIPSTUFF class from Rick Strahl] so I can go in and reset the user to what they should have access to.
lnChkSum = 0
for i = 1 to fcount()
    if field(i) = "CHKSUM"
       loop
    endif
    lcFName = field(i)
    do case
         case type(field(i)) $ "C/M"
                  lcData = eval(lcFName)
         case type(field(i)) $"N/I"
                  lcData = Str(eval(lcFName))
         case type(field(i)) = "D"
                  lcData = DtoC(eval(lcFName))
         case type(field(i)) = "T"
                  lcData = TtoC(eval(lcFName, 1))
         case type(field(i)) = "L"
                  lcData = iif(eval(lcFName), "T", "F")
         case type(field(i)) = "Y"
                  lcData = Str(MtoN(eval(lcFName)))
         otherwise
                  lcData= "     "
         endcase
         lcVal = Sys[2007, lcData]                           && for some reason MS thought it neat to return an integer in character data format
         lnChkSum = lnChkSum + val(lcVal) + (i*10)   && the adding of i * 10 is arbitrary and can be whatever you want
endfor
return lnChkSum
This can now be simplified by using Transform[eval[field[i]]]
Mark McCasland
Midlothian, TX USA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform