-2

我有这个公钥和私钥,我该如何解码?

非常感谢您。

-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCl0NyHA+z9w6LiYURla4UCcedc 2SpsS4SnVGdSSEHTMsc9NbMX2fVPX9q8yyYBMypvBYnVLc7gNozr3bziLLhOGWjv Dh3zaC3/Q4wu6Osroo9Af9PoHr1riEve8ioz058mPP28TGOBb/oYa5TaeYw4GGMc mqvZMrRlGhPZIOsePQIDAQAB -----END PUBLIC KEY-----

-----开始 RSA 私有KEY----- MIICXAIBAAKBgQCl0NyHA+z9w6LiYURla4UCcedc2SpsS4SnVGdSSEHTMsc9NbMX 2fVPX9q8yyYBMypvBYnVLc7gNozr3bziLLhOGWjvDh3zaC3/Q4wu6Osroo9Af9Po Hr1riEve8ioz058mPP28TGOBb/oYa5TaeYw4GGMcmqvZMrRlGhPZIOsePQIDAQAB AoGAF74YVZzSSmPA5vlWec8zdG4q2ridwnPtwqfrQ3TlOACFVtZhloC3B26KO447 GuDgqpT4b3XnsWMeOoe9jAUrPohy0ISiYYvp0h+KHjFUFt9XH9d3hlm0VqRCExNA rG3sXXuoSmyyGIin/7l4pFJuFCyDLESQQ4zJGCicMiCpWAECQQDcM0eDTL0t/web 5XfOw5LUJLgNlAQyWmncojVB4QbT0XixZD/UBKlPyt2lwbSncRmSW7TJzb+epdHf FKCEfub9AkEAwMYbAh4VUal0q+aBGheo3N/4cZy0GC4unM15F9lxkOn06RGSmFQ5 0ulhlH3f5h5uVIFh7jT1Nk27H2EjTxHYQQJAMoDUWwnjrcP7Q8cqZlK2v084o2ya Vc4kz4SogFaTEUvOyai7du4mwvU9RsIZo/mtqsK7wTkeRM21R9vcQOc2JQJAQWf1 6fYDDb4NE/YVf6DfbnGffgzJHhstPY6Js4nXem+m5R1NO9n39JOyxAshWJaioJF1 hLj7Kf2dq7vtmvpXAQJBANAYjUpCT8cYA5XpbmeMHTw3XGuF1N2wBpfu5BNsN8Nh l0NZkzFHNpempMYTr/1TnUaeAynlevfw6/mSK40YHrQ= -----结束 RSA 私有钥匙 - - -

4

2 回答 2

0

基本上任何识别 DER 结构的 ASN.1 解码器都可以......

免费的 javascript 版本见https://lapo.it/asn1js/

于 2019-04-26T09:27:23.557 回答
0

(这使用 Python 3)

从开始菜单打开您的 CMD (windows) 或从启动板的实用程序页面打开 TERMINAL (mac)。类型:

pip install pycrypto

如果这给您一个错误,请尝试:

pip3 install pycrypto

(您可能不必这样做)在空闲窗口中选择“打开模块”,然后键入crypto. 如果它给你一个错误,那么你很好。然后,重命名cryptoCrypto大写。

回到 python 并输入这个(在编辑窗口中):

from Crypto.PublicKey import RSA
key = RSA.importKey('file.pem') # where file.pem is where your keys are stored, in the format you had in your question
public = key.publickey()

output = public.encrypt('data'.encode('utf-8'),32) # 'data' is a placeholder
output = key.decrypt('data'.encode('utf-8'))

输出将是bytes, 以转换为十六进制:

print(output.hex())
于 2019-04-27T12:02:10.980 回答