Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.
/ laravel-pgp Public archive
generated from spatie/package-skeleton-laravel

Laravel-PGP offers an effortless solution for adding PGP encryption and decryption functionality to your Laravel application. With its fully customizable options and ready-to-use scaffolding, it provides a seamless integration for a comprehensive security solution.

License

Notifications You must be signed in to change notification settings

JTD420/laravel-pgp

Repository files navigation

Automatic PGP Encryption/Decryption for your laravel application. Fully customisable and works out-the-box with the default provided scaffolding!

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Important Notice

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.

Support us

Future updates will include ways to support this project and others.

Installation

You can require the package via composer:

composer require jtd420/laravel-pgp

Installing the package

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"

Usage

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();

Generating a Keypair

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@email.com', 'RealSecurePassPhrase');
$public_key = $keypair['public_key'];
$private_key = $keypair['private_key'];

Encrypting a Message

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');

Decrypting a 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!

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Laravel-PGP offers an effortless solution for adding PGP encryption and decryption functionality to your Laravel application. With its fully customizable options and ready-to-use scaffolding, it provides a seamless integration for a comprehensive security solution.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published