Automatic PGP Encryption/Decryption for your laravel application. Fully customisable and works out-the-box with the default provided scaffolding!
Please be advised that Laravel-PGP is currently in its early stages of development (version 0.0.1) and may not be suitable for production use in critical environments.
This package provides a convenient way for Laravel users to add PGP encryption and decryption functionality to their projects, with the added bonus of default scaffolding for a chat interface.
However, as with any new software, it is still undergoing testing and refinement. We recommend that users exercise caution and carefully evaluate its suitability for their specific use case before implementing it in a live environment.
Future updates will include ways to support this project and others.
You can require the package via composer:
composer require jtd420/laravel-pgp
To install the package into your Laravel application, you need to require it using composer and run the following Artisan command:
php artisan PGP::install blade
If you prefer a dark theme, the following command can be run instead with the --dark
option:
php artisan PGP::install blade --dark
You can publish and run the migrations with:
php artisan vendor:publish --tag="PGP-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="PGP-config"
This is the contents of the published config file:
return [
/*
* To prevent naming conflicts, this prefix will be added to all Laravel-PGP migrations.
*/
'table_prefix' => 'pgp_',
/*
* Prefix added to rest of Laravel-PGP code, including routes. (Delete default to remove prefix)
*/
'prefix' => 'PGP',
/*
* Choose the layout file to be extended by the views provided in the package.
* The default layout file is set to 'PGP::layouts.app', but can be changed to match your preferred layout.
*/
'layout_file' => 'PGP::layouts.app',
/*
* Choose the section name to be used in the views provided in the package.
* The default section name is set to 'content', but it can be changed to match the section defined in your custom layout file.
* This option is only applicable if you have set a custom 'layout_file' with a different '@section()' name.
*/
'layout_section' => 'content',
'uses_custom_auth' => true,
];
Optionally, you can publish the views using
php artisan vendor:publish --tag="PGP-views"
This package includes the PGPController class located at App/Http/Controllers/PGPController
for users who want to
understand the inner workings of the package and possibly modify it. However, if all you want is the default encrypted
messaging functionality, there's no need for any additional setup. The package provides sensible defaults for easy use,
as well as being highly customizable for those who want to extend it.
To use the class and its methods, it must be imported into a controller and instantiated:
use App\Http\Controllers\PGPController;
$controller = new PGPController();
The generate_keypair
method generates a public/private keypair and returns both the public and private key as
enarmoured PGP keys.
$keypair = $controller->generate_keypair('Name', '[email protected]', 'RealSecurePassPhrase');
$public_key = $keypair['public_key'];
$private_key = $keypair['private_key'];
The encrypt
method takes a public key and a message and returns an encrypted enarmoured PGP message.
$encrypted_message = $controller->encrypt($public_key, 'secret message');
The decrypt
method takes a private key, encrypted message and passphrase and returns either the decrypted message or a
json error if decryption fails.
$decrypted_message = $controller->decrypt($private_key, $encrypted_message, 'RealSecurePassPhrase');
For more, see the wiki here!
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.