Here is a link of the updates I did to the original project.
https://drive.google.com/file/d/0B556ucir_o2kTHEtbnJvRFVFc2c/view?usp=sharingThe code is probably not perfect and CONSTRUCTIVE comments are welcome.
I think I have it stable enough to use.
This is based off the original work in the fist message of this thread in the git hub link.
I have contacted the original author to see if he is interested in adding this as a branch or whatever. If not I will just fork it on git hub.
Changes I made:
I only load the DLL once when the GPGME object is created.
You only need to create a new context and free that per operation. The original code loaded the library in each function.
Added Decrypt function that takes a source and dest filestream with the passphrase callback enabled and working.
The GPGME object now has a property called PassPhrase that you can set before a Decrypt to supply the password.
The password is passed via the callbacks hook pointer var as a null terminated string.
Changed the Keylist function to return rows of key value pairs so you can easily send across a network and use tstringlist to access.
Added a KeyListDS function that adds the keys to a tbufdataset which is returned as a stream for easy sending via TCP/IP
Added a function to output the engine information.
Added a property to access the GPGME.dll version number which is filled when the GPGME object is created.
The GPGME objects create accepts the library name and expects it to be in the same dir as the sample app.
If you want to encrypt or decrypt text, just use Tstringstream instead of Tfilestream and set ASCIIArmor to true.
Still need to add a method to import a key. This could be used on a Indy FTP server to automatically decrypt files and encypt files using public keys for relay from the
FTP server to other locations.
This is geared for use on a server with a keyring not in the default location. There are two properties one for homedir and one for cyrpto engine.
I set this to the gpghome dir in the same dir as the sample app and I set the crypto engine to the gpg.exe also contained in the app dir.
All the required DLLs and deps are included in the app dir.
The key to getting this to work is not to install the GPG or GPG4WIN setups as they add paths to the PATH system environment vars.
The GPGME dll will look for those ENV vars and attempt to use the Pineentry agent in the setup installed dirs. This is fine if you are building a desktop app, but not for a server app. you don't want a GTK dialog box popping up or trying to popup.
it will try and execute gpgconf.exe and then it won't use your keyring or gpg.exe.
The default location for the keyring is the users roaming app dir.
Again this is based off the project GPGME4Pascal on gitbhub. I do not take credit for the original work and this would not be possible without that initial work.
Many thanks to the GPGME4Pascal author.