首页>>技术分享>>php杂谈>php一段用于加解密的公共函数

php一段用于加解密的公共函数

大路 php杂谈 2024-01-22 1122

加密

    function idcard_encrytp($str)

    {

     

        $key = "123456";

        $ciphertext_raw = openssl_encrypt($str, "AES-128-CBC", $key, OPENSSL_RAW_DATA,'16bytestring');

        $ciphertext = base64_encode($ciphertext_raw);


        return $ciphertext;

    }


//解密

    function idcard_decrytp($ciphertext)

    {

        $key = "123456";

        $ciphertext_raw = base64_decode($ciphertext);

        $original_plaintext = openssl_decrypt($ciphertext_raw, "AES-128-CBC", $key, OPENSSL_RAW_DATA,'16bytestring');


        return $original_plaintext;

    }

可加密可解密,好使

标签: