How to decrypt string in php

David Jourard support at
Wed Nov 10 20:08:28 CET 2010


I have a gpg encypted string in a data field and I want to be able decrypt

Is there a simple way to do this without writing it to a file on a windows

Here is my code example:


function DecryptGPG ($string) {

	$gpg = 'c:/locationofgnupg/gpg';
      $passphrase = 'mypassword';
	$cmdline = "$gpg --no-secmem-warning --batch --passphrase
$passphrase  --decrypt $string";

	exec ($cmdline,  $stdout, $return);

	$finalstring = $stdout[0];
	return $finalstring;

$finalvalue = DecryptGPG($encryptedstuff);

echo "value=$finalvalue\n";


With this code I get:  Invalid Option "-----BEGIN" which I understand why.

David J. 

More information about the Gnupg-users mailing list