PHP code example of brightnucleus / keys

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

    

brightnucleus / keys example snippets


 namespace Vendor\Package;

use BrightNucleus\Keys\Key;

$key = new Key('my_option');
echo $key;
// Output: 'my_option'

 namespace Vendor\Package;

use BrightNucleus\Keys\UUID;

$randomUUID = UUID::uuid4();
echo $randomUUID;
// Output: random UUID, in a format similar to '123e4567-e89b-12d3-a456-426655440000'

$hashedUUID = UUID::uuid5(UUID::NAMESPACE_URL, 'https://www.brightnucleus.com');
echo $hashedUUID;
// Output: '63ab6383-0ad4-559a-b16b-afcec9cc77e9'

 namespace Vendor\Package;

use BrightNucleus\Keys\Key;

class TimestampedKey extends Key
{

    /**
     * Initialize a new TimestampedKey object.
     */
    public function __construct()
    {
        $dateTime = new \DateTimeImmutable();
        $this->data = $dateTime->getTimestamp();
    }
}

$key = new TimestampedKey();
echo $key;
// Output: Unix timestamp value in the format '1499248161';