123456789101112131415161718192021222324 |
- <?php
- namespace App\Services;
- use App\Models\ThirdToken;
- class CommonService
- {
- public static function createToken($type, $type_id, $v = 1)
- {
- $key = mt_rand();
- $hash = hash_hmac("sha1", $v . mt_rand() . time(), $key, true);
- $token = str_replace('=', '', strtr(base64_encode($hash), '+/', '-_'));
- ThirdToken::create([
- 'type' => $type,
- 'type_id' => $type_id,
- 'token' => $token,
- 'expire_at' => date('Y-m-d H:i:s', time() + 7200),
- ]);
- return $token;
- }
- }
|