Simple encoding/decoding of data and hash validation using a shared secret.
// Composer autoloader
require_once 'vendor/autoload.php';
use nurtext\SignedRequest;
// Set a shared secret
SignedRequest::setSharedSecret('my shared secret');
// Encode and hash the data
$signedRequest = SignedRequest::generate(array('hello' => 'world'));
// Debug output
var_dump($signedRequest);
// Just verify, don't return the parsed data
var_dump(SignedRequest::verify($signedRequest));
// Verify and return data if verification succeeds
var_dump(SignedRequest::parse($signedRequest));
- PHP >= 5.1.2
- ext-json
- See www.php.net/manual/en/function.hash-algos.php for a list of available algorithms