RSA 密钥转换为 PEM 文件
如何转换此 RSA 公钥: 109120132967399429278860960508995541528237502902798129123468757937266291492576446330739696001110 6039072308886100726558188253585034290 57592827629436413108566029093628 2126359538366865626758497206207862794310902180176810615217550567108238764764442605581471797071 19674283982419152118103759076030616683978566631413
to *.pem file?
How can I convert this RSA public key:
109120132967399429278860960508995541528237502902798129123468757937266291492576446330739696001110 6039072308886100726558188253585034290 57592827629436413108566029093628 2126359538366865626758497206207862794310902180176810615217550567108238764764442605581471797071 19674283982419152118103759076030616683978566631413
to *.pem file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
“pem”文件实际上并不是一种格式,不同类型的对象可以存储在称为“pem”文件的文件中。大多数情况下,这些文件包含 Base64 编码的 X509 证书或 Base64 编码的私钥对象。
假设您想要一个 X509 证书,接下来您应该意识到证书由许多字段组成,其中只有一个字段是公钥。因此需要决定其他字段的值。最后,必须使用私钥签署证书。
附言。 RSA 公钥由模数和公共指数组成。你的公众指数是多少?
A "pem" file is not really a format, and different kinds of objects may be be stored in things called "pem" files. Most often these files contain either a base64-encoded X509 certificate or else a base64-encoded private key object.
Assuming you want an X509 certificate, you should next realize that a certificate consists of many fields, only one of which is the public key. So would need to decide on the values of the other fields. Finally, a certificate must be signed, with a private key.
PS. An RSA public key consists of a modulus and a public exponent. What is your public exponent?
如果您的十六进制字符串只是从 base64 到十六进制的简单转换。然后你就可以逆转它。这是我为解决我的情况而编写的脚本(在 PHP 中):
给定 .hex 文件列表,它会转换回“.pem”。你可以像这样运行它:
If your hex string is just a simple convert from base64 to hex. Then you can reverse it. Here is the script I did (in PHP) to solve my case:
Given a list of .hex files, it convert back to ".pem". You can run it like this:
我会使用 OpenSSL。假设您拥有 DER 格式的密钥,则可以使用此命令从 DER 转换为 PEM。
如果您不确定是否拥有格式正确的 DER (ASN.1) 编码密钥,请尝试此 工具来解析您的输入文件。
I would use OpenSSL. Assuming that you have the key in DER format, you can use this command to convert from DER to PEM.
If you are not sure whether you have the correctly formatted DER (ASN.1) encoded key, try this tool to parse your input file.
首先,詹姆斯·K·波尔克总统是对的。完整的 RSA 密钥由模数和公共指数组成。
在 Java 中,java.security.interfaces 包中的 RSAPublicKey 接口可以保存格式正确的 RSA 密钥。假设您有这样的对象,转换为 PEM 格式的过程将涉及对其进行编码,如下所示:
First of all President James K. Polk is right. A complete RSA Key is formed by a modulus and a public exponent.
In Java, the interface RSAPublicKey from the package java.security.interfaces can hold well-formed RSA Keys. Assuming you have such object, the process of converting to a PEM format would involve encoding it, as follows:
使用 putty 程序,PuTTYgen 会进行此转换
use putty programs, PuTTYgen does this conversion