Package Data | |
---|---|
Maintainer Username: | Kyslik |
Maintainer Contact: | martin.kiesel@gmail.com (Martin Kiesel) |
Package Create Date: | 2017-03-06 |
Package Last Update: | 2017-04-24 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-21 03:01:07 |
Package Statistics | |
---|---|
Total Downloads: | 289 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
This package is upgraded version of cwygoda/signing package, with timestamps support to match django 1.10 functionality.
Pull this package in through Composer (development/latest version dev-master
)
{
"require": {
"kyslik/django-signer": "0.0.*"
}
}
$ composer update
add timestamp-signer service provider
Kyslik\Django\Signing\SignerServiceProvider::class,
Instantiate new Signer object:
$signer = new Kyslik\Django\Signing\Signer('secret-key');
Note:
$separator
defaults to:
,$salt
defaults todjango.core.signing
Note: Exception is thrown in case of unsuccesfull unsigning.
$signer->sign('string'); // string:UDxi2Kxw-SF3UBWhiflQNiAQWeU
$signer->unsign('string:UDxi2Kxw-SF3UBWhiflQNiAQWeU'); // string
Note: you may use
Signer::WITH_TIMESTAMP
instead oftrue
as second parameter
$signer->sign('string', true); // string:1ckUX7:o-VQHm4f82K8106IXlc36S5Cumw
$signer->unsign('string:1ckUX7:o-VQHm4f82K8106IXlc36S5Cumw', true) // string
$signer->setMaxAge(10)->unsign('string:1ckUX7:o-VQHm4f82K8106IXlc36S5Cumw', true);
$array = ['user' => 'abc'];
$dumped = $signer->dumps($array); // eyJ1c2VyIjoiYWJjIn0:1ckV8v:OFnlhdYlNBCgixtl3XErbUh2Jug
$laoded = $signer->loads($dumped);
//verify
var_dump(($loaded === $array)) // true