fork(3) download
  1. <?php
  2.  
  3. class hasher {
  4. public function send() {
  5.  
  6. $stringToSign = 'test';
  7. $key = '123456';
  8.  
  9. //Calculate Signature
  10. $signature = $this->calculateSignature($stringToSign, $key);
  11.  
  12. print_r("StringToSign: " . $stringToSign . PHP_EOL);
  13. print_r("Key: " . $key . PHP_EOL);
  14. print_r("Signature Caculated: " . $signature . PHP_EOL);
  15. }
  16.  
  17. private function calculateSignature($stringToSign, $key) {
  18.  
  19. // check signature
  20. $hash = strtoupper(hash_hmac('sha256', $stringToSign, hex2bin($key), false));
  21. return $hash;
  22. }
  23. }
  24.  
  25. $h = new hasher;
  26. $h->send();
  27.  
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
StringToSign: test
Key: 123456
Signature Caculated: DA3617974490FB780F04F06287BF93B0F24A7F15970471146428B943FFDC7850