将 PHP RSA 公钥转换为 Android 公钥
我正在开发基于客户端服务器的应用程序。
我会以这种格式
当我将其保存到字符串中时,
获得公钥。现在我想在我的Android(Java代码)中使用这个键,我该如何使用它?
I am working on a client server based application.
Where I get PublicKey in this format
as I saved it into String.
Now I want to use this key in my Android(Java code), how can I use this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您需要从您提供的 pem 格式生成公钥,这是我执行此操作的方法:
以下是我如何使用它来读取(解码)使用提供的公钥签名的内容。
First you need to generate the public key from the pem format you provided, here is my method for doing this:
And here is how I use it to read (decode) the content signed with the public key provided.
有一个名为“bouncycastle”的项目,我们在 j2me 上使用它,但它也可以在 android 上运行。它可用于处理 openssl 证书。
bouncycastle.org
Java KeyStore 实现:
导入 java.security.cert.Certificate
import java.security.KeyStore
并自述了很多,因为 java 不直接支持 openssl 密钥,java 带来了自己的机制。
KeyStore 内容的 Java 示例:
There is a project called "bouncycastle" we use it on j2me but it woll work on android too. it can be used to handle openssl certificates.
bouncycastle.org
Java KeyStore implementation:
import java.security.cert.Certificate
import java.security.KeyStore
and readme a LOT because openssl keys are not directly supported by java which is bringing their own mechanisms.
Java example for KeyStore stuff: