passwordRSA:function(){if(this.isMsgLogin)return!1;var t =$("#J_Exponent").val(), i =$("#J_Module").val();if(""== t ||""== i)$("#J_Timestamp").removeAttr("name"),this.$dom.inputs.password2.removeAttr("name");else{var n =news.RSAKey;
n.setPublic(i, t);var e = n.encrypt(this.$dom.inputs.password.val());this.$dom.inputs.password.removeAttr("name"),this.$dom.inputs.password2.val(e)
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization
modulus ="98639b48645bdaadc930c1e2316b9d07223f3808e9192788a1e2183ff5a33f393ff51f9a6f65050600f4e77890c333c18ff2d5ca9e2259a1696aa4398c7ca809034911671ef06e760a12da4aa285fcd028edaa5e8e3a70d1fed92649ee7189ef0bec70ffa8e26ce57ede52d5593bc36c48abe16c50cc1fd7c1479e53cb0cde99"
exponent =10001# 从little-endian格式的数据缓冲data中解析公钥模数并公钥defpopulate_public_key(modulus, exponent):# convert bytes to integer with int.from_bytes# 指定从little格式将bytes转换为int,一句话就得到了公钥模数,省了多少事
n =int(modulus,16)
e = exponent
# 使用(e, n)初始化RSAPublicNumbers,并通过public_key方法得到公钥# construct key with parameter (e, n)
key = rsa.RSAPublicNumbers(e, n).public_key(default_backend())return key
# 将公钥以PEM格式保存到文件中defgenerate_pub_key(pub_key, pem_name):# 将公钥编码为PEM格式的数据
pem = pub_key.public_bytes(
encoding=serialization.Encoding.PEM,format=serialization.PublicFormat.SubjectPublicKeyInfo
)print(pem)# 将PEM个数的数据写入文本文件中withopen(pem_name,'w+')as f:
f.writelines(pem.decode())return pem
if __name__ =='__main__':
pub_key = populate_public_key(modulus, exponent)
pem_file = r'pub_key.pem'
generate_pub_key(pub_key, pem_file)