本文整理汇总了Python中jwkest.jwk.RSAKey.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python RSAKey.to_dict方法的具体用法?Python RSAKey.to_dict怎么用?Python RSAKey.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jwkest.jwk.RSAKey
的用法示例。
在下文中一共展示了RSAKey.to_dict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_and_store_rsa_key_pair
# 需要导入模块: from jwkest.jwk import RSAKey [as 别名]
# 或者: from jwkest.jwk.RSAKey import to_dict [as 别名]
def create_and_store_rsa_key_pair(name="pyoidc", path=".", size=1024):
key = RSA.generate(size)
keyfile = os.path.join(path, name)
f = open("%s.key" % keyfile, "w")
f.write(key.exportKey("PEM"))
f.close()
f = open("%s.pub" % keyfile, "w")
f.write(key.publickey().exportKey("PEM"))
f.close()
rsa_key = RSAKey(key=key)
rsa_key.serialize()
# This will create JWK from the public RSA key
jwk_spec = json.dumps(rsa_key.to_dict(), "enc")
f = open(keyfile + ".jwk", "w")
f.write(str(jwk_spec))
f.close()
return key
示例2: rsa_load
# 需要导入模块: from jwkest.jwk import RSAKey [as 别名]
# 或者: from jwkest.jwk.RSAKey import to_dict [as 别名]
import json
import os
import argparse
from jwkest.jwk import RSAKey, rsa_load, dump_jwks
__author__ = 'rolandh'
parser = argparse.ArgumentParser()
parser.add_argument('-n', dest="name", default="pyoidc",
help="file names")
parser.add_argument('-p', dest="path", default=".",
help="Path to the directory for the files")
parser.add_argument('-k', dest="key", help="Key file")
args = parser.parse_args()
key = rsa_load(args.key)
rsa_key = RSAKey(key=key)
rsa_key.serialize()
# This will create JWK from the public RSA key
jwk_spec = json.dumps(rsa_key.to_dict(), "enc")
keyfile = os.path.join(args.path, args.name)
_out = dump_jwks([{"key":key, "use":"enc"}])
f = open(keyfile + ".jwk", "w")
f.write(_out)
f.close()