src/Utils/Rsa2Encrypt.php
public function decrypt($content)
    {
        if ($this->key === false) {
            return '';
        }

        $res = openssl_get_privatekey($this->key);
        if (empty($res)) {
            throw new \Exception('您使用的私钥格式错误，请检查RSA私钥配置');
        }

        //用base64将内容还原成二进制
        $decodes = base64_decode($content);

        $str = '';
        $dcyCont = '';
        foreach ($decodes as $n => $decode) {
            if (!openssl_private_decrypt($decode, $dcyCont, $res)) {
                echo "<br/>" . openssl_error_string() . "<br/>";
            }
            $str .= $dcyCont;
        }

        openssl_free_key($res);
        return $str;
    }
public function decrypt($content)
    {
        if ($this->key === false) {
            return '';
        }

        $res = openssl_get_privatekey($this->key);
        if (empty($res)) {
            throw new \Exception('您使用的私钥格式错误，请检查RSA私钥配置');
        }

        //用base64将内容还原成二进制
        $decodes = base64_decode($content);

        $str = '';
        $dcyCont = '';
        foreach ($decodes as $n => $decode) {
            if (!openssl_private_decrypt($decode, $dcyCont, $res)) {
                echo "<br/>" . openssl_error_string() . "<br/>";
            }
            $str .= $dcyCont;
        }

        openssl_free_key($res);
        return $str;
    }
public function decrypt ( $ content ) { if ( $ this -> key === false ) { return '' ; } $ res = openssl_get_privatekey ( $ this -> key ) ; if ( empty ( $ res ) ) { throw new \ Exception ( '您使用的私钥格式错误，请检查RSA私钥配置'); } //用base64将内容还原成二进制 $ decodes = base64_decode ( $ content ) ; $ str = '' ; $ dcyCont = '' ; foreach ( $ decodes as $ n => $ decode ) { if ( ! openssl_private_decrypt ( $ decode , $ dcyCont , $ res ) ) { echo "<br/>" . openssl_error_string ( ) . "<br/>" ; } $ str .= $ dcyCont ; } openssl_free_key ( $ res ) ; return $ str ; }
RSA2解密 此处秘钥是用户私有秘钥
@param string $content 需要解密的内容，密文
@throws \Exception
@return string
@author helei
RSA2解密 此处秘钥是用户私有秘钥