PHP code example of wtframework / security

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

    

wtframework / security example snippets


use WTFramework\Config\Config;

Config::set([
  'security' => [
    'encryption_key' => 'ec5964323dc239ab63417a0f98ff1eef', // openssl rand -hex 16
    'hash_salt' => 'f93101e3a5f4f09f8c1a9ac0f9301c6e', // openssl rand -hex 16
    'password_pepper' => '2429fc585eef890c13e2c5307dcb02f23d8d83ea86740d864a6e79e2a7613cd1a95efd42', // openssl rand -hex 36
  ],
]);

use WTFramework\Security\Password;

$hash = Password::hash('password');

if (Password::verify('password', $hash))
{
  // ...
}

if (Password::needsRehash($hash))
{
  // ...
}

use WTFramework\Security\Crypt;

$encrypted = Crypt::encrypt('text');

$text = Crypt::decrypt($encrypted);

$hashed = Crypt::hash('text');

$uuid = Crypt::uuid();