A Laravel package for cryptographic signature generation and verification.
jmrashed/laravel-cryptographic-signatures is a Laravel package for a laravel package for cryptographic signature generation and verification..
It currently has 0 GitHub stars and 8 downloads on Packagist (latest version v1.0.5).
Install it with composer require jmrashed/laravel-cryptographic-signatures.
Discover more Laravel packages by jmrashed
or browse all Laravel packages to compare alternatives.
Last updated
A Laravel package for generating and verifying cryptographic signatures using RSA keys. This package provides easy-to-use methods for securing your data through signatures, ensuring authenticity and integrity.
You can install the package via Composer by running the following command in your Laravel project:
composer require jmrashed/laravel-cryptographic-signatures
Publish the package's configuration file to customize your keys:
php artisan vendor:publish --provider="Jmrashed\LaravelCryptographicSignatures\Providers\CryptoSignaturesServiceProvider" --tag="config"
This will create a cryptosignature.php file in the config/ directory, where you can specify the paths to your private and public keys.
In your .env file, set the paths to your private and public keys:
CRYPTO_PRIVATE_KEY=storage/keys/private.key
CRYPTO_PUBLIC_KEY=storage/keys/public.key
How to generate RSA keys: storage/keys/private.key and storage/keys/public.key
openssl genrsa -out storage/keys/private.key 2048
openssl rsa -in storage/keys/private.key -pubout -out storage/keys/public.key
Make sure your keys are stored securely in the specified paths.
php artisan vendor:publish --provider="Jmrashed\LaravelCryptographicSignatures\Providers\CryptoSignaturesServiceProvider" --tag="config"
php artisan vendor:publish --provider="Jmrashed\LaravelCryptographicSignatures\Providers\CryptoSignaturesServiceProvider" --tag="keys"
Once the package is installed and configured, you can easily generate and verify cryptographic signatures.
Use the CryptoSignature facade to generate a signature for your data.
use Jmrashed\LaravelCryptographicSignatures\Facades\CryptoSignature;
$data = 'Sensitive data to be signed';
$signature = CryptoSignature::generateSignature($data);
echo "Generated Signature: " . $signature;
You can also verify a signature to ensure the integrity and authenticity of the data.
use Jmrashed\LaravelCryptographicSignatures\Facades\CryptoSignature;
$data = 'Sensitive data to be verified';
$signature = 'previouslyGeneratedSignature';
$isVerified = CryptoSignature::verifySignature($data, $signature);
if ($isVerified) {
echo "The signature is valid!";
} else {
echo "The signature is invalid!";
}
Here’s a complete example that demonstrates generating and verifying a signature:
use Jmrashed\LaravelCryptographicSignatures\Facades\CryptoSignature;
$data = 'Sensitive data to be signed';
// Generate the signature
$signature = CryptoSignature::generateSignature($data);
// Verify the signature
$isVerified = CryptoSignature::verifySignature($data, $signature);
if ($isVerified) {
echo "The data is verified!";
} else {
echo "Signature verification failed!";
}
To run tests for the package, use the following command:
php artisan test
Make sure your keys are properly configured in the .env file before running the tests.
The package is open-sourced software licensed under the MIT license.
Contributions are welcome! Please feel free to fork the repository, submit issues, and send pull requests.
If you encounter any issues or have questions, feel free to open an issue in the GitHub repository.