Package to handle public private keys for your application and other uses, stored in a rsa_keystore
model which can be linked to any other model.
Install via composer
composer require custom-d/eloquent-async-keys
Note! This and next step are optional if you use laravel>=5.5 with package auto discovery feature.
Add service provider to config/app.php
in providers
section
CustomD\EloquentAsyncKeys\ServiceProvider::class,
Register package facade in config/app.php
in aliases
section
CustomD\EloquentAsyncKeys\Facades\EloquentAsyncKeys::class,
php artisan vendor:publish --provider="CustomD\EloquentAsyncKeys\ServiceProvider" --tag="config"
php artisan asynckey
namespace CustomD\EloquentAsyncKeys;
-
EloquentAsyncKeys::create([$keySize = null], [$overwrite = false]): self
- This allows you to create a new set of keys and returns an instance of the class. -
EloquentAsyncKeys::encrypt($data, [$version = null]): array
- this allows you to encrypt a new message and optionally set then algorithm version -
EloquentAsyncKeys::encryptWithKey($publicKey, $data, [$version = null]): array
- this allows you to encrypt a new message with a provided key and optionally set then algorithm version -
EloquentAsyncKeys::decrypt($data, [$key = null]): string
- Decrypts the message -
EloquentAsyncKeys::decryptWithKey($privateKey, $data, $key = null): string
- this allows you to decrypt a message with a provided key -
EloquentAsyncKeys::getPublicKey(): string
- gets the current public key -
EloquentAsyncKeys::getPrivateKey(): string
- gets the current private key -
EloquentAsyncKeys::getSalt(): string
- gets the current salt -
EloquentAsyncKeys::getDecryptedPrivateKey(): resource
- gets the current decrypted private key -
EloquentAsyncKeys::setKeys([$publicKey = null], [$privateKey = null], [$password = null]): self
- set the public, private and password -
EloquentAsyncKeys::setPublicKey(?string $publicKey = null): self
- sets/unsets the public key -
EloquentAsyncKeys::setPrivateKey(?string $privateKey = null): self
- sets/unsets the private key -
EloquentAsyncKeys::setSalt($salt = null): self
- sets/unsets/generates salt, (pass true to generate a new salt) -
EloquentAsyncKeys::setPassword(?string $password = null): self
- set/unset the password for the current private key -
EloquentAsyncKeys::setNewPassword(string $newPassword, $newSalt = false): void
- sets a new password onto your current privateKey
We have added a faker library to use to populate your keystores:
use CustomD\EloquentAsyncKeys\Faker\Keygen;
...
$faker = Factory::create(Factory::DEFAULT_LOCALE);
$faker->addProvider(new Keygen($faker));
$keyset = $faker->keygenCollection($faker->password(), true);
will return your with keyset as an array containing the following structure
[
'password' => x,
'salt' => x,
'publicKey' => x,
'privateKey' => x
]
.
If you discover any security related issues, please email instead of using the issue tracker.