Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Enrypting and decrypting data files(PGP)
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01001196
Message ID:
01001205
Vues:
19
We had something similar here (using GPG instead). I ended up using the CreateProcess WinAPI to launch the command line and monitor the app till it closed. It's worked pretty well to date. That was about three months ago.

Here's the code for that:
LOCAL lsProcessInfo as String,;
	 lsStartupInfo as String,;
	 lnResult as Integer,;
	 lnProcessHandle as Integer,;
	 lhndStartedProcess as Integer

DECLARE LONG WaitForSingleObject IN WIN32API;
	LONG hHandle,;
	LONG dwMilliseconds

DECLARE LONG CreateProcessA IN WIN32API AS "CreateProcess";
	STRING lpApplicationName,;
	STRING lpCommandLine,;
	LONG lpProcessAttributes,;
	LONG lpThreadAttributes,;
	SHORT bInheritHandles,;
	LONG dwCreationFlags,;
	STRING lpEnvironment,;
	STRING lpCurrentDirectory,;
	STRING lpStartupInfo,;
	STRING lpProcessInformation

DECLARE LONG CloseHandle IN WIN32API; 
	LONG hObject

lsProcessInfo = REPLICATE(CHR(0), 16)
lsStartUpInfo = CHR(68) + ;
			 REPLICATE(CHR(0), 43) + ;
			 CHR(1) + ;
			 REPLICATE(CHR(0), 23)

THIS.WriteStringToLog("Copying Files for Encryption...")
COPY FILE (ADDBS(THIS.m_sOutputLocation) + "PRI_074.txt") TO "C:\PRI_074.TXT"

THIS.WriteStringToLog("Beginning Encryption")
lnResult = CreateProcess(0, ;	&& NULL
			 '"C:\program files\gnupgp\gpg" --batch --yes -e -r MyKeyName -o ' +;
			 '"c:\PRI_074.asc" "C:\PRI_074.txt"' + CHR(0), ;
			 0,;
			 0,;
			 0,;
			 0,;
			 0,;
			 "C:\"+CHR(0),;
			 @lsStartUpInfo,;
			 @lsProcessInfo)

IF lnResult = 1
	*	CreateProcess() started our app, but we have to wait until it finishes loading
	*	Strip the process handle from the PROCESS_INFORMATION structure

	lhndStartedProcess = (((ASC(SUBSTR(lsProcessInfo, 4, 1)) * 256) + ;
			     ASC(SUBSTR(lsProcessInfo, 3, 1))) * 256 + ;
			     ASC(SUBSTR(lsProcessInfo, 2, 1))) * 256 + ;
			     ASC(LEFT(lsProcessInfo, 1))

	*	As long as the other process exists, wait for it

	WaitForSingleObject(lhndStartedProcess, 0xFFFFFFFF)
	CloseHandle(lhndStartedProcess)

	COPY FILE "C:\PRI_074.ASC" TO (ADDBS(THIS.m_sOutputLocation) + "PRI_074.gpg")

	DELETE FILE "C:\PRI_074.TXT"
	DELETE FILE "C:\PRI_074.ASC"
One thing I did find out (about GPG it may not apply to PGP) is that it does not like long path names.

HTH,
Richard

>Hi,
>
> Our client wants us to send the data files using PGP. They sent me one ASC file also. I don't know how can I do this in Foxpro. I will appreciate any information on PGP and how we implement that in Visual fox pro 7.0.
>
>Thanks
>Bharat
State of Florida, DCF
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform