• ADADADADAD

    api接口数据怎么加密[ 网络知识 ]

    网络知识 时间:2024-11-19 12:05:06

    作者:文/会员上传

    简介:

    使用AES加密算法对api接口数据进行加密,具体方法如下:

    以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。

    使用AES加密算法对api接口数据进行加密,具体方法如下:

    <?php

    //$key previously generated safely, ie: openssl_random_pseudo_bytes

    $key='123456789';

    $plaintext="hello world";

    //$cipher = "aes-128-cbc";

    $cipher = "AES-128-ECB";

    if (in_array($cipher, openssl_get_cipher_methods()))

    {

    // $iv='1111111111111111';

    $iv='';

    $ciphertext = openssl_encrypt($plaintext, $cipher, $key, OPENSSL_RAW_DATA, $iv);

    $ciphertext =base64_encode($ciphertext);

    //store $cipher, $iv, and $tag for decryption later

    $original_plaintext = openssl_decrypt(base64_decode($ciphertext), $cipher, $key, OPENSSL_RAW_DATA, $iv);

    var_dump( $original_plaintext);

    var_dump( $ciphertext);

    }

    api接口数据怎么加密.docx

    将本文的Word文档下载到电脑

    推荐度:

    下载
    热门标签: 数据加密api