PHP code example of matasarei / euspe

1. Go to this page and download the library: Download matasarei/euspe 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/ */

    

matasarei / euspe example snippets


$crypto = new Matasar\Euspe\Crypto(); // initializes the library

try {
    // EUSignTest.php \develop()
    $result = $crypto->develop('path/to/private_key', 'password', 'encrypted_data');
    var_dump($result->signInfo->data); // decrypted data
} catch (\Matasar\Euspe\Exception\DecryptionException $e) {
    //...
}

$crypto = new Matasar\Euspe\Crypto();
try {
    $hash = $crypto->hash('path/to/file', Matasar\Euspe\Crypto::HASH_FILE);
    var_dump(base64_encode($hash));

    $hash = $crypto->hash('qwerty', Matasar\Euspe\Crypto::HASH_DATA); // hash string
    var_dump(base64_encode($hash));
} catch (\Matasar\Euspe\Exception\EncryptionException $e) {
    //...
}

$crypto = new Matasar\Euspe\Crypto();
try {
    /** @var \Matasar\Euspe\Dto\SignInfo $info */
    $info = $crypto->verify('signature', 'hash');
} catch (\Matasar\Euspe\Exception\DecryptionException $e) {
    //...
}
sh
cp .../eusphpe.ini /etc/php/7.4/mods-available/eusphpe.ini
cp -R .../eusphpe_extension /usr/lib/php/eusphpe_extension
sh
ln -s /etc/php/7.4/mods-available/eusphpe.ini /etc/php/7.4/fpm/conf.d/20-eusphpe.ini
ln -s /etc/php/7.4/mods-available/eusphpe.ini /etc/php/7.4/cli/conf.d/20-eusphpe.ini