Last active
August 21, 2020 12:53
-
-
Save fahmiegerton/3e5180939bb306438e82c383e500877a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$payload = `[ | |
{ | |
"id": 929, | |
"bank_id": "gCjM", | |
"account_number": 4591596, | |
"bank_type": "bca", | |
"date": "01/01/2018", | |
"amount": "104082", | |
"description": "bayar spanduk lagi", | |
"type": "CR", | |
"balance": 1900000 | |
} | |
]`; | |
$body = []; | |
$data = array( | |
'id' => 929, | |
'bank_id' => 'gCjM', | |
'account_number' => 4591596, | |
"bank_type" => "bca", | |
"date" => "01/01/2018", | |
"amount" => 104082, | |
"description" => "bayar spanduk lagi", | |
"type" => "CR", | |
"balance" => 1900000 | |
); | |
$body[] = $data; | |
$httpstatuscode = 200; | |
$signaturefromheader = '9dbec372a25bb68dc8351e9fe9c2c55ef7b907c0e35e143e45b31a8c73ab9860'; | |
$apikey = 'itsmyapikeyfrommoota'; | |
$jsonBody = json_encode($body, JSON_UNESCAPED_SLASHES); | |
$requestBody = strtolower(hash('sha256', $jsonBody)); | |
// $stringToSign = strtoupper('POST') . ':' . $requestBody . ':' . $httpstatuscode; | |
$stringToSign = strtoupper('POST') . $requestBody . $httpstatuscode; | |
// $stringToSign = $data['id'].':'.$httpstatuscode.':'; | |
// $stringToSign = $data['id'] . $httpstatuscode . $data['amount'] . $apikey; | |
// $stringToSign = $data['id'] . $data['bank_id'] . $data['account_number'] . $data['bank_type'] . $data['date'] . $data['amount'] . $data['description'] . $data['type'] . $data['balance']; | |
$signature = hash_hmac('sha256', $jsonBody, $apikey); | |
// $signature = hash_hmac('sha256', json_encode($payload, JSON_UNESCAPED_SLASHES), $apikey); | |
var_dump($signature); | |
var_dump($jsonBody); | |
// var_dump(base64_encode($signature)); | |
($signature == $secret) ? var_dump('yeayy') : var_dump('alamak'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment