dq_609586475 2019-04-22 02:40
浏览 123

需要将php openssl代码转换为python

I'm working in a personal project where I need to read a p12 cert in Python3. For now, i need to use openssl_pkey_get_private and openssl_pkey_get_details equivalents from php in Python3, but i didn't found a way to do it

I have searched the web for the equivalent for python without a look.

The PHP code that i need to convert to python is as follows:

$complem = openssl_pkey_get_details(openssl_pkey_get_private($this->privateKey));
$this->Modulus    = base64_encode($complem['rsa']['n']);
$this->Exponent   = base64_encode($complem['rsa']['e']);

For openssl_pkey_get_private I wrote this code:

def openssl_pkey_get_private(private_key):
    detailed_key = RSA.importKey(private_key)
    return detailed_key

Above code gives an array with a, e, n, etc. But for openssl_pkey_get_details I have no idea about what to do.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 matlab有关常微分方程的问题求解决
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?
    • ¥100 求三轴之间相互配合画圆以及直线的算法
    • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
    • ¥15 名为“Product”的列已属于此 DataTable