PHP code example of 3ncr / tokencrypt-php

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

    

3ncr / tokencrypt-php example snippets


$tokenCrypt = new \ThreeEncr\TokenCrypt($secret, $salt, 1000);

$token = '08019215-B205-4416-B2FB-132962F9952F'; // your secret you want to encrypt 
$encryptedSecretToken = $tokenCrypt->encrypt3ncr($token);
// now $encryptedSecretToken === '3ncr.org/1#pHRufQld0SajqjHx+FmLMcORfNQi1d674ziOPpG52hqW5+0zfJD91hjXsBsvULVtB017mEghGy3Ohj+GgQY5MQ'

// ... some time later in another context ...  

$decryptedSecretToken = $tokenCrypt->decrypt3ncr($encryptedSecretToken); 
// now $decryptedSecretToken === ''08019215-B205-4416-B2FB-132962F9952F';

$encConfig = json_decode(file_get_contents('config.json'), false); 
$config = $token->decrypt3ncrArray($encConfig);