PHP code example of inspirecz / security

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

    

inspirecz / security example snippets

 php
$hash = 'edb433bdd7c13851c7c68cb31a5acf33';
$symetric = new \Inspire\Security\Crypt\OpenSSLSymetricEncoderDecoder($hash);

$plaintext = 'Hello world!';
$ciphertext = $symetric->encode($plaintext);
echo $symetric->decode($ciphertext); // vystup: Hello world!
 php
class TestService
{

    /** @var \Inspire\Security\Crypt\OpenSSLSymetricEncoderDecoder */
    private $cryptService;

    /**
     * @param \Inspire\Security\Crypt\OpenSSLSymetricEncoderDecoder $cryptService
     */
    public function __construct(\Inspire\Security\Crypt\OpenSSLSymetricEncoderDecoder $cryptService)
    {
        $this->cryptService = $cryptService;
    }

    /**
     * @param string $text
     *
     * @return string
     */
    public function useCrypt(string $text): string
    {
        return $this->cryptService->encode($text);
    }

}
 php
$generator = new \Inspire\Security\Password\RandomTokenGenerator();
echo $generator->generate(); // výstup: edb433bdd7c13851c7c68cb31a5acf33