Android (Java) 中的 PublicKey 和 PrivateKey 构造函数

发布于 2024-10-01 14:39:21 字数 159 浏览 0 评论 0原文

我想将我用应用程序生成的公钥和私钥保留在一个文件中,这样我就可以再次使用完全相同的密钥..但我意识到Android中没有任何用于PublicKey和PrivateKey对象的构造函数..所以当我可以保留它们并阅读它们时,我仍然无法在我的应用程序中重用它们..

有人可以告诉我如何完成它吗?

i want to keep the public and private keys I've generated with my application in a file so I could use the exact same keys another time.. but i realize that there isn't any constructor for PublicKey and PrivateKey object in Android.. so when I could keep them and read them, I still can't reuse them in my application..

could someone tell me how the way that it could be done?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ˇ宁静的妩媚 2024-10-08 14:39:22

PublicKey 和 PrivateKey 的 getEncoded 方法返回字节适合提供给 X509EncodedKeySpec 构造函数的数组(对于公钥)和 PKCS8EncodedKeySpec (对于私钥)。这些 KeySpec 反过来可以与适当的 KeyFactory 一起使用来重新生成私有密钥键。

The getEncoded methods of PublicKey and PrivateKey return byte arrays that should be suitable for supplying to the constructors for X509EncodedKeySpec (for the PublicKey) and PKCS8EncodedKeySpec (for the PrivateKey). These KeySpecs in turn may be used with the appropriate KeyFactory to regenerate the private keys.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文