* the encryption dll SET LIBRARY TO VFPEncryption71.FLL ADDITIVE ThisForm.Grid1.Recordsource = "" SELECT *,.F. AS STATUS FROM MODULES INTO CURSOR CRSMOD ORDER BY toopen READWRITE USE IN SELECT("modules") * decrypt it and display cSecretKey = Thisform.csecretkey && cSecretKey = "lImo1zIBREhsr7KgMI9ZmTLPvY2qNgOz" LOCAL ctemp as String SCAN REPLACE pieces WITH STRTRAN(decrypt(ALLTRIM(pieces),cSecretKey, 2),CHR(0),""),; ofx WITH STRTRAN(decrypt(ALLTRIM(ofx),cSecretKey, 2),CHR(0),""),; stringx WITH SUBSTR(STRTRAN(decrypt(ALLTRIM(stringx),cSecretKey, 2),CHR(0),""),4),; toopen WITH SUBSTR(STRTRAN(decrypt(ALLTRIM(toopen),cSecretKey, 2),CHR(0),""),4) Replace status WITH IIF(SUBSTR(ofx,4)="ALLOW",.T.,.F.) ENDSCAN SELECT * FROM crsmod INTO CURSOR CRSMODULES ORDER BY toopen READWRITE USE IN SELECT("crsmod") ThisForm.Grid1.Recordsource = "crsModules" GO TOP ThisForm.Grid1.Refresh ThisForm.BindControls = .T.After changes where strings may be changed & records added the table is again encrypted:
SCAN IF EMPTY(pieces) DELETE LOOP ENDIF IF ALLTRIM(ofx) = "COMPANY" REPLACE pieces WITH encrypt(ALLTRIM(pieces),cSecretKey, 2),; ofx WITH encrypt(ALLTRIM(ofx),cSecretKey, 2),; stringx WITH encrypt(ALLTRIM(stringx),cSecretKey, 2) ELSE REPLACE ofx WITH LEFT(pieces,3)+IIF(status=.T.,"ALLOW","DISALLOW") REPLACE stringx WITH LEFT(ALLTRIM(pieces),3)+ALLTRIM(stringx) REPLACE toopen WITH RIGHT(ALLTRIM(pieces),3)+ALLTRIM(toopen) REPLACE pieces WITH encrypt(ALLTRIM(pieces),cSecretKey, 2),; ofx WITH encrypt(ALLTRIM(ofx),cSecretKey, 2),; stringx WITH encrypt(ALLTRIM(stringx),cSecretKey, 2),; toopen WITH encrypt(ALLTRIM(toopen),cSecretKey, 2) ENDIF ENDSCAN LOCAL cFile AS String cFile = ALLTRIM(ThisForm.Text1.Value) * make a backup COPY FILE(cFile) TO ADDBS(JUSTPATH(cFile))+JUSTSTEM(cFile)+".BAK" SELECT pieces,ofx,stringx,toopen FROM crsModules INTO cursor cTemp * copy it to get rid of deleted records COPY TO (cFile) ThisForm.ReleaseHowever depending of the number of records, suddenly a field somewhere in the middle of the table which decrypted correctly earlier will throw up an error and leave the table 1/2 decrypted and useless.