PHP code example of townsend / akm
1. Go to this page and download the library: Download townsend/akm 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/ */
townsend / akm example snippets
use TownsendSecurity\Akm;
use TownsendSecurity\KeyServer;
$akm = new Akm();
$key_server = new KeyServer(
$server_name,
$server_host,
$path_to_local_cert,
$path_to_ca_cert
);
$akm->addKeyServer($key_server);
$saved_key = $akm->getKeyValue('my_key');
$encrypted_data = $akm->encrypt('test data', 'my_key');
$plaintext = $akm->decrypt($encrypted_data);
assert($plaintext === 'test data');