1. Go to this page and download the library: Download uma/psr7-hmac 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/ */
MA\Psr7Hmac\Signer;
use UMA\Psr7Hmac\Verifier;
//// CLIENT SIDE
$psr7request = new \Zend\Diactoros\Request('http://www.example.com/index.html', 'GET');
// GET /index.html HTTP/1.1
// host: www.example.com
$signer = new Signer('secret');
$signedRequest = $signer->sign($psr7request);
// GET /index.html HTTP/1.1
// host: www.example.com
// authorization: HMAC-SHA256 63IQ8RWDbC9p4ipNrkJz0e0UeGiBrR96zkNdujE5cl8=
// signed-headers: host,signed-headers
//// SERVER SIDE
$verifier = new Verifier();
var_dump($verifier->verify($signedRequest, 'secret'));
// true
var_dump($verifier->verify($signedRequest, 'another secret'));
// false
// Headers added after calling sign() do not break the verification, as
// they are not
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.