将密钥库与 javax.crypto 结合使用进行文件加密/解密
建议我看这里: http://exampledepot.com/egs/javax.crypto/ DesFile.html为使用import javax.crypto加密/解密的源代码。我已经通过 keytool 生成了密钥,现在我不知道如何将生成的密钥传递到该应用程序中进行加密和解密。
我的情况是,我有一个在线存储的 XML 文件(它存储配置详细信息),在使用 XML 解析器解析它之前,我必须对其进行解密。首先,我当然应该在它上线之前对其进行加密。
问题是:如何将生成的密钥传递到第一行链接中可见的代码中?
谢谢
I was advised to look here: http://exampledepot.com/egs/javax.crypto/DesFile.html for the source code of encryption/decryption using import javax.crypto. I have generated my key via keytool and now I don't know how to pass my generated keys into that application for encryption and decryption.
My situation is, that I have a XML file stored online (it stores configuration details) and before I parse it with a XML parser I have to decrypt it. First of all I should of course encrypt it, before it goes online.
Question is: How to pass my generated keys into code visible in link in first row?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如何加载 KeyStore 记录在 JavaDoc 中KeyStore 类:
加载密钥存储后,您可以加载密钥:
密钥别名是您使用 keytool 指定的别名。
使用
myKey
您可以初始化 Cipher 实例或使用例如 CipherOutputStream / CipherInputStreamHow to load a KeyStore is documented in the JavaDoc of the KeyStore class:
Once you have loaded the key store you can load the key:
The key alias is the one you have specified using keytool.
Using the
myKey
you can initialize the Cipher instance or use for example a CipherOutputStream / CipherInputStream