12345678910111213141516171819202122232425262728293031323334 |
- <?php
- /**
- * Created by KLXQ
- * user: youyi
- * Date:2024/6/14 16:29.
- * Tencent SDK.
- * 目前主要用于腾讯事件回调验签.
- */
- namespace App\Http\Helpers\Tencent;
- class TlsEventSig
- {
- private string $key;
- private string $body;
- public function __construct($key, $body)
- {
- $this->key = $key;
- $this->body = $body;
- }
- private function __hmacsha256()
- {
- $hash = hash_hmac('sha256', $this->body, $this->key, true);
- return base64_encode($hash);
- }
- public function genEventSig()
- {
- return $this->__hmacsha256();
- }
- }
|