php aes解密去掉末尾的乱码

正文开始

    private static function _aesDecode($data,$privateKey, $iv=''){
        $encryptedData = base64_decode($data);
        //新版
        $decrypted = openssl_decrypt($encryptedData, 'AES-128-CBC', $privateKey, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $iv);
//     $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $privateKey, $encryptedData, MCRYPT_MODE_CBC, $iv);

        $len = strlen($decrypted);
        $pad = ord($decrypted[$len-1]);
        return substr($decrypted, 0, strlen($decrypted) - $pad);
//        return rtrim($decrypted);
    }

https://www.uoften.com/article/70389.html

正文结束

PHP接口(interface)和抽象类(abstract) 阿里云的身份证识别SDK alibabacloud/client 的安装