Any tutorials on public key encryption in java? [closed]

自古美人都是妖i 提交于 2019-12-03 06:08:00
Loki

There are quite a few resources on the web about that. Basically it turns around the KeyPairGenerator class.

See http://www.informit.com/articles/article.aspx?p=170967&seqNum=4 for an example program.

Normally, you use public key encryption to encrypt a symmetric key, in part because public key encryption is very slow. Typically, you'd send the recipient the following, so that they can decrypt your message:

  1. The symmetric key, encrypted with the recipient's public key.
  2. Parameters for the algorithms used, usually an initialization vector for the symmetric cipher.
  3. Identifiers for the encryption algorithms used.
  4. The ciphertext—the actual message, encrypted under the symmetric cipher.

I found the sample code in the JCE documentation sufficient to get things working.

The standard format for bundling all of this information up is the Cryptographic Message Syntax, or CMS, which is used by S/MIME in email applications. I recommend using Bouncy Castle's libraries; they are solid, fairly simple, and actively maintained. The reference documentation is a bit weak, but they do provide code examples.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!