RSA应用指数与模生成公钥(ArcGIS Server)

参考:

https://www.cnblogs.com/luo30zhao/p/10515594.html

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


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-----


posted @ 2019-08-21 17:22  ParamousGIS  阅读(665)  评论(0编辑  收藏  举报