PHP code example of jmrashed / laravel-cryptographic-signatures

1. Go to this page and download the library: Download jmrashed/laravel-cryptographic-signatures 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/ */

    

jmrashed / laravel-cryptographic-signatures example snippets


use Jmrashed\LaravelCryptographicSignatures\Facades\CryptoSignature;

$data = 'Sensitive data to be signed';
$signature = CryptoSignature::generateSignature($data);

echo "Generated Signature: " . $signature;

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!";
}

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!";
}
bash
php artisan vendor:publish --provider="Jmrashed\LaravelCryptographicSignatures\Providers\CryptoSignaturesServiceProvider" --tag="config"
env
CRYPTO_PRIVATE_KEY=storage/keys/private.key
CRYPTO_PUBLIC_KEY=storage/keys/public.key
bash
php artisan vendor:publish --provider="Jmrashed\LaravelCryptographicSignatures\Providers\CryptoSignaturesServiceProvider" --tag="config"
php artisan vendor:publish --provider="Jmrashed\LaravelCryptographicSignatures\Providers\CryptoSignaturesServiceProvider" --tag="keys"
bash
php artisan test