Files
xk-api-yii/helpers/helpers.php
2024-11-19 11:11:02 +08:00

29 lines
751 B
PHP

<?php
if (!function_exists('ds')) {
function ds($data, $exit = false)
{
exit(json_encode([
'code' => 19980617,
'msg' => '测试返回',
'data' => $data
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT
));
}
}
if (!function_exists('ase_encode')) {
function ase_encode($data)
{
// 获取随机字符串30个
$random = '';
for ($i = 0; $i < 30; $i++) {
$random .= chr(mt_rand(32, 126));
}
return base64_encode($random. base64_encode($data));
}
}
if (!function_exists('ase_decode')) {
function ase_decode($data)
{
return base64_decode(substr(base64_decode($data), 30));
}
}