PHP code example of snoopyebo / test_signature
1. Go to this page and download the library: Download snoopyebo/test_signature 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/ */
snoopyebo / test_signature example snippets
namespace Snoopy\TestSignature\Decrypt\Lib;
class Signature
{
public static function getSignature($params, $secret)
{
$signature = '';
ksort($params);
foreach ($params as $k => $v) {
if ($v instanceof \SplFileInfo) {
$v = md5_file($v->getPathname());
} else if ($v instanceof \CURLFile) {
$v = md5_file($v->name);
}
$signature .= sprintf('%s=%s&', $k, $v);
}
$signature .= $secret;
return md5($signature);
}
public static function getToken($app, $ticket, $time)
{
return md5(sprintf("%s%d%s", $app, $time, $ticket));
}
}