first commit
This commit is contained in:
25
support/helpers.php
Normal file
25
support/helpers.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user