Here we are describing a solution how to encrypt/decrypt strings using Virgil PHP SDK. You are able to make an encryption ONLY if you have already registered on the Dashboard, created an App and generated a key pair (private and public keys).

Encrypt Data on a Public Key:

use Virgil\CryptoImpl\VirgilCrypto;

$crypto = new VirgilCrypto();

// prepare a message
$messageToEncrypt = "Hello, Bob!";

// encrypt the message
$encryptedData = $crypto->encrypt($messageToEncrypt, $receiverPublicKey);

Decrypt the encrypted data with a Private Key:

use Virgil\CryptoImpl\VirgilCrypto;

$crypto = new VirgilCrypto();

// prepare data to be decrypted
$decryptedData = $crypto->decrypt($encryptedData, $receiverPrivateKey);


Also, at our repo on GitHub you can find the full solution how to encrypt/decrypt  files of all sizes. 

Did this answer your question?