Java programming resources
I am a Java programmer. I have successfully done some secret key encryption and decryption. I can use the private key to sign a message and verify with the public key, but I still need some coding examples on how to encrypt with the public key and decrypt with the private key or vice versa. Can you recommend any resources on this topic?
SearchSecurity.com members gain immediate and unlimited access to breaking industry news, virus alerts, new hacker threats, highly focused security newsletters, and more -- all at no cost. Join me on SearchSecurity.com today!
Michael S. Mimoso, Editorial Director
I find the best place to go for Java code examples is the Sun Developer Network (SDN) run by Sun Microsystems, the developers of Java technology. SDN has two articles, which include the types of example you are after. The first is
Cryptography: The Ancient Art of Secret Messages at
http://java.sun.com/developer/technicalArticles/Security/Crypto/. The second is
Java 2 Cryptography Extension: Encrypting and Decrypting Data at
http://java.sun.com/developer/technicalArticles/Security/JCE/. This second article examines the classes in the JCE javax.crypto package and, in particular, the classes that are central to data encryption and decryption, the Cipher and KeyGenerator. They also provide pseudo code segments for an encryption and decryption program. An encryption program uses a secret key to encrypt a text string and a sealed object to wrap the secret key with the recipient's public key. A decryption program receives the encrypted text and wrapped session key over the network, then unwraps the secret key by using its private key and uses the recovered secret key to decrypt the message.
Two other articles that cover code examples are Using RSA encryption with Java by Aviran Mordo at http://www.aviransplace.com/index.php/archives/2004/10/12/using-rsa-encryption-with-java/2/ and Public Key Cryptography 101 Using Java by Richard G. Baldwin: http://www.developer.com/java/ent/article.php/3447491
Finally, if you don't already have it, I suggest looking into the Java Cryptography Extension (JCE)Reference Guide for the Java 2 SDK, Standard Edition, v 1.4 is available at http://java.sun.com/j2se/1.4.2/docs/guide/security/jce/JCERefGuide.html
Dig Deeper
-
People who read this also read...
This was first published in December 2005