dbd-net/signed-request

There is no license information available for the latest version (1.0.0001) of this package.

Sign and validate HTTP requests

1.0.0001 2021-01-13 20:05 UTC

This package is auto-updated.

Last update: 2024-10-29 06:00:15 UTC


README

$key = 'testkey123';
$data = ['field1' => 'value1'];

$signer = new DBD\SignedRequest\Signer($key);
// or...
// $signer = DBD\SignedRequest\Signer::init($key);

$signedData = $signer->sign($data);
// or..
// $signedData = DBD\SignedRequest\Signer::init($key)->sign($data);

print_r($signedData);
// Array
// (
//     [field1] => value1
//     [hashed_data] => {"field1":"value1"}
//     [hash] => ab8c056075e89bb8e1fed1ed0dec7436
// )

Validate a request

$key = 'testkey123';
$signedData = [
    'field1' => 'value1',
    'hashed_data' => '{"field1":"value1"}',
    'hash' => 'ab8c056075e89bb8e1fed1ed0dec7436',
];

$signer = new DBD\SignedRequest\Signer($key);
// or...
// $signer = DBD\SignedRequest\Signer::init($key);

$isValid = $signer->validate($signedData);
// or...
// $isValid = DBD\SignedRequest\Signer::init($key)->validate($signedData);

print $isValid;
// true