Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
API error with VfpEncryption71.fll
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Produits tierce partie
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01412793
Message ID:
01413505
Vues:
78
>>I just implemented some data encryption using VfpEncryption71.fll. It seems to work fine, but when I close the application, I get an error "API call caused an exception." I believe it is on the line of code that says "SET LIBRARY TO." Any ideas?
>
>Hi Elyse,
>
>Is there anyway that you could give me some code that would reproduce this problem? If so, I can step through the VC++ code in the FLL and find out what is going on here and fix it. There isn't any UNLOAD function being called within the FLL when it is released, so it shouldn't actually be doing anything that can cause an exception. Also, i'm hopeful that if you are able to give me a repo of the problem that it repos in VFP 9.0 SP2 as well (I can't bring myself to reinstall VFP 8 in order to debug this). Thanks.


Craig

I too get adifferent intermittent error depending of the data, not like the original poster gets. I tried to use this lib to encrypt a table of settings but depending on the number of records, the decryption would fail with an error leaving me with a half decrypted and useless table.

I have a table with 4 fields

pieces C(50)
ofx C(50)
toopen C(50)
stringx C(50)

This is the code used to decrypt the table and display in a grid:
* 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.Release
However 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.

So I have a situation where everything works fine and then I add a single record at the end and a field in the middle which decrypted correctly earlier will not anymore making the table useless . It was because of this that I had to stop using it in my app.

BErnard
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform