美文网首页
php 7++加密解密

php 7++加密解密

作者: 爱学习的小仙女呀 | 来源:发表于2018-07-26 16:12 被阅读0次

    ```

    <?php

    header('Content-Type: text/plain;charset=utf-8');

    $data = 'level_img/15325853427068.png';

    $key = 'oScGU3fj8m/tDCyvsbEhwI91M1FcwvQqWuFpPoDHlFk='; //echo base64_encode(openssl_random_pseudo_bytes(32));

    $iv = 'w2wJCnctEG09danPPI7SxQ=='; //echo base64_encode(openssl_random_pseudo_bytes(16));

    echo '内容: '.$data."\n";

    $encrypted = openssl_encrypt($data, 'aes-256-cbc', base64_decode($key), OPENSSL_RAW_DATA, base64_decode($iv));

    echo '加密: '.base64_encode($encrypted)."\n";

    $encrypted = base64_decode('qaFLGz3UfNk0NOdiGJEJav+okwpK3KSrrBZI+O8lHH4=');

    $decrypted = openssl_decrypt($encrypted, 'aes-256-cbc', base64_decode($key), OPENSSL_RAW_DATA, base64_decode($iv));

    echo '解密: '.$decrypted."\n";

    ?>

    ```

    相关文章

      网友评论

          本文标题:php 7++加密解密

          本文链接:https://www.haomeiwen.com/subject/ufvbmftx.html