26 lines
520 B
PHP
26 lines
520 B
PHP
<?php
|
|
if (!function_exists('jsonResponse')) {
|
|
function jsonResponse($data = [], $msg = 'success', $code = 200)
|
|
{
|
|
return json([
|
|
'code' => $code,
|
|
'msg' => $msg,
|
|
'data' => $data
|
|
]);
|
|
}
|
|
}
|
|
|
|
if (!function_exists('generateToken')) {
|
|
function generateToken(): string
|
|
{
|
|
return bin2hex(random_bytes(32));
|
|
}
|
|
}
|
|
|
|
if (!function_exists('hashToken')) {
|
|
function hashToken(string $token): string
|
|
{
|
|
return hash('sha256', $token);
|
|
}
|
|
}
|