1. Go to this page and download the library: Download ksfraser/ksf_gpg library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ksfraser / ksf_gpg example snippets
use ksfraser\GPG\Services\GPGService;
$gpg = new GPGService();
// Sign a file
$signed = $gpg->signFile($filePath, $contactEmail);
// Encrypt for recipient
$encrypted = $gpg->encryptForContact($filePath, $contactEmail);
// Sign and encrypt
$protected = $gpg->signAndEncrypt($filePath, $contactEmail);
// Password-based encryption (no key
use ksfraser\GPG\Adapter\GnuPGAdapterFactory;
$adapter = GnuPGAdapterFactory::create();
// Encrypt a file to multiple recipients
$encrypted = $adapter->encryptWithRecipients(
'/tmp/invoice.pdf',
['[email protected]', '[email protected]']
);
use ksfraser\GPG\Hook\GPGHookRequest;
use ksfraser\GPG\Hook\GPGTarget;
// Create a request
$request = new GPGHookRequest('/tmp/file.pdf', GPGHookRequest::OPERATION_SIGN_ENCRYPT);
$request->addTarget(new GPGTarget('customer', 123, '[email protected]'));
// Process via GPGService
$response = $service->processHookRequest($request, $contactResolver, $keyResolver);
// Inspect results
if ($response->isSuccess()) {
$encryptedPaths = $response->getEncryptedPaths();
$signedPaths = $response->getSignedPaths();
}
use ksfraser\GPG\Adapter\GnuPGAdapterFactory;
// Automatically selects best available adapter
$adapter = GnuPGAdapterFactory::create();
// Sign
$adapter->signFile('/tmp/doc.pdf', '[email protected]');
// Encrypt
$adapter->encryptFile('/tmp/doc.pdf', '[email protected]');
// Password-based
$adapter->encryptWithPassword('/tmp/doc.pdf', 'secret');
$adapter->decryptWithPassword('/tmp/doc.pdf.gpg', 'secret');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.