PHP code example of pentagonal / pair-creator
1. Go to this page and download the library: Download pentagonal/pair-creator 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/ */
pentagonal / pair-creator example snippets
use \Pentagonal\PairCreator\Lib\Pair;
/**
* @param mixed $masterPassword
*/
$masterPassword = 'Strong Password';
/**
* Instantiate Pair
*/
$pair = new Pair($masterPassword);
/**
* @param mixed $dataToBeEncrypted any data type to encrypted
*/
$dataToBeEncrypted = [
'My Data' => 'this data'
];
/**
* Encrypt The Data
*
* @param array $encryptedDataAndKey
* [
* Pair::KEY_NAME => (string key)
* Pair::DATA_NAME => (string data)
* ]
*/
$encryptedDataAndKey = $pair->generateData($dataToBeEncrypted);
$encryptedKey = $encryptedDataAndKey[Pair::KEY_NAME];
$encryptedData = $encryptedDataAndKey[Pair::DATA_NAME];
/**
* Decrypt The Data
* @param mixed $decrypted
* followed the data saved
*/
$decrypted = $pair->verify($encryptedKey, $encryptedData);