PHP code example of originphp / security

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

    

originphp / security example snippets


use Origin\Security\Security;
$hashed = Security::hash('foo');

$hashed = Security::hash('foo',['pepper'=>'A random string']);

$hashed = Security::hash('foo',['type'=>'sha1']);

$list = hash_algos()

$hashed = Security::hashPassword('secret');

$hashed = Security::hashPassword('secret');
$bool = Security::verifyPassword($input,$hashed); // input is user inputted password

use Origin\Security\Security;
$key = Security::generateKey(); // ESaCestIJvuAo3NUAtHAZG9DqmFJZtyx

use Origin\Security\Security;
$key = '33d80476167cc95c363bf7df3c95e1d1';
$encrypted = Security::encrypt('foo',$key);

use Origin\Security\Security;
$key = '33d80476167cc95c363bf7df3c95e1d1';
$encrypted = 'ohRRdAydx+4wfOd7Vm+LHmmV9zBH+3r0WLQylyPMPu2RvCjX9FVgoeUBZuLYBTLM4x9NeZX7U0bUvE1bucATSQ==';
$plain = Security::decrypt($encrypted,$key);

$randomString = Security::random(); // 5f31ecf661dabb04

$hex = Security::hex(); // gpgf67ezotl06wqs
$base36 = Security::base36(); // 13owqvwcgb426rvq
$base58 = Security::base58(); // SyqBFAtGfNxZkZMQ
$base62 = Security::base62(); // oc1eIfAHKWWt5zrO
$base64 = Security::base64(); // v3xsI6O+g6LsuY4+
// url safe
$base64 = Security::base64(16,true); // YPT9rp-i6jqXWCvA

$uid = Security::uid(); // O64cjBxfz2JPhyCQ

$uid = Security::uuid(); // 38c67382-d3ab-4430-a27e-0c719813c09f

$uid = Security::uuid(['macAddress'=>true]); // ac337932-e4e5-11e9-928f-8bda39fe8887

$uid = Security::uuid(['macAddress'=>'00:0a:95:9d:68:16']); // 769c6fa4-e4e5-11e9-b8d5-000a959d6816