PHP code example of kidfund / thin-transit-client

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

    

kidfund / thin-transit-client example snippets


/**
 * @return TransitClient|null
 * @throws Exception
 */
protected function getTransitClient()
{
    $enabled = config('vault.enabled');

    if (!$enabled) {
        return null;
    }

    $vaultAddr = config('vault.addr');
    $vaultToken = config('vault.token');

    if ($vaultToken === null || $vaultToken === 'none') {
        throw new Exception('Vault token must be configured');
    }

    $client = new TransitClient($vaultAddr, $vaultToken);

    return $client;
}

/**
 * @return void
 */
public function register()
{
    $this->app->singleton(TransitClient::class, function () {
        return $this->getTransitClient();
    });
}

$encrypted = $client->encrypt($key, $plaintext);

$encrypted = $client->encrypt($key, $plaintext, $context);

$plaintext = $client->decrypt($key, $cipherText,);

$plaintext = $client->decrypt($key, $cipherText, $context);