RSA應用指數與模生成公鑰(ArcGIS Server)

參考:html

http://www.javashuo.com/article/p-wttjzroc-md.htmlspa

https://blog.csdn.net/skiof007/article/details/78678490.net


pip3 install cryptography


>>> from cryptography.hazmat.backends import default_backend
>>> from cryptography.hazmat.primitives.asymmetric import rsa
>>> from cryptography.hazmat.primitives import serialization
>>> mod="8c42b648787779dc66a0e15e85725db3b284e2cf073f6c05025f41a3cb9b211b148fae4bd87c907ee5a9d4039a1ea2a970cb6bf09a117438ed1ac4998e097aa3"
>>> e=10001
>>> n = int(mod,16)
>>> key = rsa.RSAPublicNumbers(e, n).public_key(default_backend())
>>> print(key)

>>> pem = key.public_bytes(encoding=serialization.Encoding.PEM, format=serialization.PublicFormat.SubjectPublicKeyInfo)
>>> print(pem)
b'-----BEGIN PUBLIC KEY-----\nMFswDQYJKoZIhvcNAQEBBQADSgAwRwJBAIxCtkh4d3ncZqDhXoVyXbOyhOLPBz9s\nBQJfQaPLmyEbFI+uS9h8kH7lqdQDmh6iqXDLa/CaEXQ47RrEmY4JeqMCAicR\n-----END PUBLIC KEY-----\n'

得出公鑰爲:

-----BEGIN PUBLIC KEY-----
MFswDQYJKoZIhvcNAQEBBQADSgAwRwJBAIxCtkh4d3ncZqDhXoVyXbOyhOLPBz9s
BQJfQaPLmyEbFI+uS9h8kH7lqdQDmh6iqXDLa/CaEXQ47RrEmY4JeqMCAicR
-----END PUBLIC KEY-----code

相關文章
相關標籤/搜索