1. Go to this page and download the library: Download andrew-svirin/eusphpe-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/ */
andrew-svirin / eusphpe-php example snippets
$user = new \AndrewSvirin\EUSPE\User(
'user-name',
'server.name',
'dat|jks',
'bDataKey',
'secret'
);
$serverStorage = new \AndrewSvirin\EUSPE\ServerStorage($this->serversDir);
$keyRingStorage = new \AndrewSvirin\EUSPE\KeyRingStorage($this->keysDir);
$certStorage = new \AndrewSvirin\EUSPE\CertificateStorage($this->certsDir);
$serverStorage->clearExpired(); // Run it by cron every 1 hour.
$keyRingStorage->clearExpired(); // Run it by cron every 1 hour.
$certStorage->clearExpired(); // Run it by cron every 1 hour.
$keyRing = $keyRingStorage->prepare($user);
$cert = $certStorage->prepare($user);
try {
$server = $serverStorage->prepare($user, $cert);
$server->open();
$client = new \AndrewSvirin\EUSPE\Client();
$client->open();
$settings = $client->getFileStoreSettings();
$this->assertNotEmpty($settings);
if (!$keyRingStorage->exists($keyRing)) {
$keyRing->setPassword($user->getPassword());
$keyRing->setType($user->getKeyType());
if ($keyRing->typeIsDAT()) {
$keyRing->setPrivateKeys([$user->getKeyData()]);
}
else {
$keyRing->setPrivateKeys($client->retrieveJKSPrivateKeys($user->getKeyData()));
}
$keyRingStorage->store($keyRing, $this->secretToken);
}
$keyRingStorage->load($keyRing, $this->secretToken);
if (!$cert->hasCerts()) {
foreach ($keyRing->getPrivateKeys() as $privateKey) {
$client->readPrivateKey($privateKey, $keyRing->getPassword());
$client->resetPrivateKey();
}
}
$certificates = $client->parseCertificates($cert->loadCerts());
$this->assertNotEmpty($certificates);
if ($keyRing->typeIsJKS()) {
$sign = $client->signData('Data for sign 123', $keyRing->getPrivateKeyStamp(), $keyRing->getPassword());
$signsCount = $client->getSignsCount($sign);
$this->assertNotEmpty($signsCount);
for ($i = 0; $i < $signsCount; $i++) {
$signerInfo = $client->getSignerInfo($sign, $i);
$this->assertNotEmpty($signerInfo);
}
}
} finally {
if (isset($client)) {
$client->close();
}
if (isset($server)) {
$server->close();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.