php加密解密

<?php
// 这是系统自动生成的公共文件


/**
 * 快捷返回json数据
 */
function rjson($code = 200, $msg = '', $data = '', $count = '')
{
    return json(['code' => $code, 'msg' => $msg, 'data' => $data, 'count' => $count]);
}


/**
 * Aes加密
 */
function encrypts($data)
{
    //php7.1 以上版本用法
    return base64_encode(openssl_encrypt($data, "AES-128-ECB", 'anbin', OPENSSL_RAW_DATA));
}


/**
 * Aes解密
 */
function decrypts($data)
{
    //php7.1 以上版本用法
    return openssl_decrypt(base64_decode($data), "AES-128-ECB", 'anbin', OPENSSL_RAW_DATA);
}


posted @ 2024-07-09 15:50  Anbin啊  阅读(6)  评论(0)    收藏  举报