· 7 years ago · Sep 19, 2018, 10:52 AM
1 <?php>
2 $consumerID = "xx";
3 $secretKey = "xx";
4 $userPcare ="xx";
5 $passPcare ="xx";
6
7 //print cons ID
8 echo "X-cons-id: " . $consumerID."<br>";
9
10 //print timestamp
11 date_default_timezone_set('UTC');
12 $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));
13 echo "X-timestamp: " . $tStamp . "<br>";
14
15
16 //Computes the signature by hashing the salt with the secret key as the key
17 $signature = hash_hmac('sha256', $consumerID."&".$tStamp,$secretKey, true);
18 $encodedSignature = base64_encode($signature);
19 echo "X-signature: " . $encodedSignature . "<br>";
20
21 //generate x-authorization
22 $encodedAuthorization=base64_encode("$userPcare:$passPcare:$kodeAplikasi");
23 echo "X-authorization: " ."Basic ". $encodedAuthorization. "<br>"; <?php>