Python equivalent of PHP openssl_public_decrypt

Viewed 23

I am trying to decrypt a cipher text. I am already able to decrypt the cipher text with PHP openssl_public_decrypt with public key. Like this...

    function decrypt_RSA($cipher, $public_key)
        {
            $DECRYPT_BLOCK_SIZE = 256;
            $decrypted = '';
    
            $data = str_split(base64_decode($cipher), $DECRYPT_BLOCK_SIZE);
    
            foreach ($data as $chunk) {
                $partial = '';
    
                $decryptionOK = openssl_public_decrypt($chunk, $partial, $public_key, OPENSSL_PKCS1_PADDING);
    
                if ($decryptionOK === false) {
                    return false;
                }
                $decrypted .= $partial;
            }
            return $decrypted;
        }

My question is how can I implement this exact decryption with python?

0 Answers
Related