Digitally Signing Data

Now that you know how to digitally sign data, you'll be happy to know that the Signature class in the java.security package takes care of most of the work for you. You don't have to go through the trouble of computing the message digest or encrypting it. You just create a Signature object, feed it a public or private key along with the data, and ask it either to sign the data or verify a signature.

There are a few combinations of message digests and encryption algorithms you can use. First, there are two types of public key encryption you can use: DSA (Digital Signature Algorithm) or good old RSA. There are three message digest algorithms available with the JDK: MD2 (Message Digest version 2), MD5 (Message Digest version ...

Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.