· 9 years ago · Oct 24, 2016, 12:18 PM
1 $consumerID = "24769";
2 $secretKey = "6sX4467121";
3 $userPcare ="pkmindustri";
4 $passPcare ="123456";
5 $kodeAplikasi="095";
6
7 /*
8 * print cons id
9 *
10 */
11 echo "X-cons-id: " . $consumerID."<br>";
12
13 /*
14 * printtimestamp
15 *
16 */
17 date_default_timezone_set('UTC');
18 $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));
19 echo "X-timestamp: " . $tStamp . "<br>";
20
21
22 /*
23 * Computes the signature by hashing the salt with the secret key as the key
24 *
25 */
26 $signature = hash_hmac('sha256', $consumerID."&".$tStamp,$secretKey, true);
27 $encodedSignature = base64_encode($signature);
28 echo "X-signature: " . $encodedSignature . "<br>";
29
30
31 /*
32 * generate x authorization
33 */
34 $encodedAuthorization=base64_encode("$userPcare:$passPcare:$kodeAplikasi");
35 echo "X-authorization: " ."Basic ". $encodedAuthorization. "<br>";