PHP code example of micseres / micro-service-dh
1. Go to this page and download the library: Download micseres/micro-service-dh 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/ */
micseres / micro-service-dh example snippets
$this->dh = new DiffieHellman(true);
$requestToBob = [
'p' => $this->dh->getPrime(),
'g', $this->dh->getGenerator(),
'public_key', $this->dh->getPublicKey()
];
//...
$pass = $this->dh->getSharedKey($responseFromBob->public_key)
$this->dh = new DiffieHellman(false);
$this->dh->generatePrimaryAsSlave($requestFromBob['p'], $requestFromBob['g']);
$pass = $this->dh->getSharedKey($requestFromBob->public_key)