热卖商品
新闻详情
Python OpenSSL基本操作接口_涟漪、的博客-CSDN博客
来自 : CSDN技术社区
发布时间:2021-03-25
记录一下OpenSSL包的一些操作
# !/usr/bin/python3# -*- coding: utf-8 -*-import OpenSSLfrom OpenSSL.crypto import sign,verify,PKeyimport timefrom dateutil import parserkey PKey()key.generate_key(OpenSSL.crypto.TYPE_RSA, 2048)crt OpenSSL.crypto.dump_publickey(OpenSSL.crypto.FILETYPE_PEM, key)pri OpenSSL.crypto.dump_privatekey(OpenSSL.crypto.FILETYPE_PEM, key)print(crt)print(pri)# openssl x509 -inform DER -in test.cer -out certificate.crtwith open(r C:\\Users\\admin\\Desktop\\2_1328217234828578816\\asu2x9.com\\asu2x9.com.crt , r ) as fp: crt_data fp.read()keydata -----BEGIN PRIVATE KEY-----MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDJdDelWqqMdbdeUAwG10NNY7qX rwKaDbJO8XtscXuj2lJoAvrnQnsO4C0JXXiuR26aNFPwVJTx/tVNk98WMIGWvh5nsKyPT6oERnSr4fYkMvL3WjVz2oda/BhOw4XtMZ0OGJjhav6zBrW6hX1XchmKGCXwsjIuxjfhPCIBShCtUUDl ih PNxpRehdJjvHwlcZ9EH8Dt28ZVyjst9Xf4AOD2wCehmN0XFsY018mP/U/QKuEEX9gH3UL8ADZDUwaecbQZEFu9we5cTUPfNBrPV5fp5oFggn qZTRBVHDw01jmF ydfHQ4OjHLbMDVQhYGpGarOIo2A8hpptymKdj77AgMBAAECggEALf9vRT4yeufV p7kYBt roj67gC NtIc0E3pn6BbxWDRdZIppp6wyVO8y2VSSXZjJ1EPmdpWZfLfnFFOTOInSzQyT/LEGdaKG 3rq4OQzQ4iumXPriIx5I3k0Q6e5SLNvXOyY27 GcHIzxGb e5z9394rq43Ej5GK6M7GJO04aYCXtBqHbw9eZyLPcWVZKVNZyUa3s2gnoJmH5aWrfATfY8rEu1ut7HL8/tVFw hpG3vddTLQFPj94R481XRR0hVN5S6BxnMmWkro9nzIHRquo/D80jSI0jQ Hbfq8HCoxn7cmB8Ik0mSob/YT pNli/iUBfaD/aFgFafdh4EFskQQKBgQDqJeJm6HRYWTuN0MGdzD3M gKYpaKqvfEH0xtlN9pgQL08gvSsNm/SRLAVgLpufBbsjbu2hGB4AIWvwHZbimpqexluH/bejesiCUAtSPE2CpJFBeqzD3tY30rGnE00XluMZ6z v/ZHGYMdpnj3lIwFqb46j6yWfHo0TBYBXPFSKQKBgQDcQTpzul4GOfovyfqS8j9uID MfLV0DDsehoedwo8FDPebPyPZ5oybTN k99uiOzAZArI080PlVFSqhXrMgP1P4biSH0UGFiGDQWYkUxhhI6Dsn6EF05KrklJZjYkwrSLne9n9DU2iw0PghuruzJHZB4CESJnra718D8F9 d4UgwKBgQCmoFsjfJz/GlFFNJ/0WZpJOkmKs6S0 QKD3PmL6FlhUfDZFSBlRUACVJsyUi9Z3Li7kolY849rFoQMdFxF/JSKPhv0wI6ABmKkEA05rMTq/k7lC7bfwk63CgA opBWiieAHW Awr7SDhe i 9d0LpsdUVIi2H4nZChktu EJQzMQKBgC65i7vnSnEJtaCTuZuY1on3P2P/RMM0oQoNwhFep9aLdK zilh8h1Ge0kb96dMVuVNk9gczoDCzXi66mF1v880RdoVRKuRqp3tf0VpdYmuhEk AYbmJs7DAHsYut27jG d9p7X L30a7XhhRs YCEzBQatOd5Cwz4bVFNgzvMAfAoGBANqLPmzCyrr9AGSQeOMutDsPXJ5ZBncN1ZhDhP4P4IP3qOElRXvKbLqSplpYVFNs/CKJFTIj FP77K0hxgKA3uDADJro7BI4/DDr3faowo8zENhm KBSOvUtoAOmorI/aKsKcggmG9ulanOxWo2 nbhRG7LbUaRSNsS6sAFASF8DM81-----END PRIVATE KEY----- sskey OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, keydata)cert OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, crt_data)# print(sskey)signdata1 sign(sskey, hello .encode(), sha1 )signdata2 sign(sskey, haha .encode(), sha1 )print(signdata1)print(signdata2)conse verify(cert, signdata1, hello .encode(), sha1 )# print(conse)if __name__ __main__ : pass
点赞 评论
本文链接: http://avgsrl.immuno-online.com/view-742185.html
发布于 : 2021-03-25
阅读(0)
最新动态
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
2021-03-25
公司介绍
品牌分类
联络我们