PHP code example of italix / crypto

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

    

italix / crypto example snippets


$verdict = $this->limiter->hit('login:' . mb_strtolower($email), 5, '15 minutes');

if ($verdict->is_exceeded()) {
    return $this->show('pages/login', [
        'error'         => 'rate_limited',
        'retry_after_n' => $verdict->retry_after_n(),
    ]);
}

$token_c = $signer->sign(['user_id' => 12], 'password_reset', '+2 hours');

$claims = $signer->verify($token_c, 'password_reset');

if (!$claims->is_valid()) {
    // error_code(): malformed | unknown_key | tampered | expired | wrong_purpose
}

$user_id = (int) $claims->get('user_id');

$stored = $cipher->encrypt($iban);
$iban   = $cipher->decrypt($stored);   // null when it cannot be authenticated
bash
php src/Libs/Italix/Crypto/tests/SignerTest.php
php src/Libs/Italix/Crypto/tests/LimiterTest.php