This guide shows how to customize a Private Key storage during using the Virgil PHP SDK (API V4).

By default, Virgil SDK stores a Private Key after its generation into a project's file. 

In order to change a Private Key storage during using PHP SDK need to implement a KeyStorageInterface and then use the following code:

use Virgil\Sdk\Api\VirgilApiContext;
use Virgil\Sdk\Api\AppCredentials;
use Virgil\Sdk\Buffer;
use Virgil\Sdk\Api\VirgilApi;
$virgilApiContext = VirgilApiContext::create(
   [
       // use Application Access Token
       VirgilApiContext::AccessToken => '[YOUR_ACCESS_TOKEN_HERE]',
       // user Application's credentials for work with Virgil Cards
       VirgilApiContext::Credentials => new AppCredentials(
           '[YOUR_APP_ID_HERE]', Buffer::fromBase64('[YOUR_APP_PRIVATE_KEY_HERE]'), '[YOUR_APP_PRIVATE_KEY_PASS_HERE]'
       ),
       //VirgilApiContext::KeysPath => '/Users/Kuzich/.virgil/storage',
   ]
);
$virgilApiContext->setKeyStorage(KeyStorageInterface $keyStorage);


Also you can implement your own mechanism for storing Private Keys. 

Did this answer your question?