yangzailu

导航

php 加密解密

php 加密解密

  <?php

  
    function encryptWithOpenssl($data,$key,$iv){
        return base64_encode(openssl_encrypt($data,"AES-128-CBC",$key,OPENSSL_RAW_DATA,$iv));
    }

    public function tests1(){
        //2r/4AGxjLgAKVaUkl1pSsA==
       // $res = $this->encryptWithOpenssl('password1', '26627hshs','hewa2020Yes54N21');

        $RES = $this->decryptWithOpenssl('9YlkklI5BYi53VhiWJ5LJw==','26627hshs','hewa2020Yes54N21');
       dd($RES);
    }

    function decryptWithOpenssl($data,$key,$iv){
        return openssl_decrypt(base64_decode($data),"AES-128-CBC",$key,OPENSSL_RAW_DATA,$iv);
    }

 

posted on 2022-09-21 17:27  飞离地平线  阅读(55)  评论(0编辑  收藏  举报