1. Go to this page and download the library: Download salibhdr/typhoon-url-signer 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/ */
salibhdr / typhoon-url-signer example snippets
'providers' => [
// Other service providers...
SaliBhdr\UrlSigner\Laravel\ServiceProviders\UrlSignerServiceProvider::class,
],
use SaliBhdr\UrlSigner\Md5UrlSigner;
//your sign key
$signKey = 'EKtF4lFP6D1FjBGtSRIk1gGn2YCRmtGPocBWV39wAeM=';
// default ttl is 7200 seconds
// pass null to make url's without expire time
$ttl = 7200;
$urlSigner = new Md5UrlSigner($signKey,$ttl);
use SaliBhdr\UrlSigner\HmacUrlSigner;
//your sign key
$signKey = 'EKtF4lFP6D1FjBGtSRIk1gGn2YCRmtGPocBWV39wAeM=';
$algorithm = 'sha1';
// default ttl is 7200 seconds
// pass null to make url's without expire time
$ttl = 7200;
$urlSigner = new HmacUrlSigner($signKey,$algorithm,$ttl);
use SaliBhdr\UrlSigner\Signers\Md5;
use SaliBhdr\UrlSigner\Signers\Hmac;
use SaliBhdr\UrlSigner\Signers\Rsa;
use phpseclib\Crypt\RSA as BaseRSA;
//-------------Md5 signer example-------------
//your sign key
$signKey = 'EKtF4lFP6D1FjBGtSRIk1gGn2YCRmtGPocBWV39wAeM=';
$signer = new Md5($signKey);
//-------------Hmac signer example------------
$signer = new Hmac($signKey);
//-------------Rsa signer example-------------
/* Rsa needs 2 extra parameters
* a public_key and a private_key
* It will not work if you don't provide these two
*/
$algorithm = 'sha1'; // default is sha256
$signMode = BaseRSA::SIGNATURE_PKCS1;
$signer = new Rsa($algorithm,$signMode);
$signer->setPublicKey('----RSA PUBLIC KEY HERE----');
$signer->setPrivateKey('----RSA PRIVATE KEY HERE----');
use SaliBhdr\UrlSigner\Signatures\Signature;
// default ttl is 7200 seconds
// pass null to make url's without expire time
$ttl = 7200;
$signature = new Signature($signer,$ttl);
use SaliBhdr\UrlSigner\UrlSigner;
$urlSigner = new UrlSigner($signature);