PHP code example of hktr92 / php-secrecy

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

    

hktr92 / php-secrecy example snippets




use Hktr92\Secrecy\Secrecy;
use Hktr92\Secrecy\SecrecyFactory;

/** @var Secrecy $password */
$password = SecrecyFactory::create("my super secret value")->unwrap();

echo "User password is $password"; // outputs "User password is <redacted>"

$pdo = new PDO(...);
$stmt = $pdo->prepare("INSERT INTO `users` SET `email` = ?, `password` = ?");
$stmt->execute(['[email protected]', password_hash($password->expose())]); // works as expected