The MessageDigest Class
The java.security.MessageDigest
class is an abstract class that
represents a hash code and its associated algorithm. Concrete
subclasses (actually concrete subclasses of
java.security.MessageDigestSPI
, though the
difference isn’t relevant from a client’s point of view)
implement particular, professionally designed, well-known hash code
algorithms. Thus, rather than constructing instances of this class
directly, you ask the static
MessageDigest.getInstance()
factory method to
provide an implementation of an algorithm with a particular name.
Table 10.1 lists the standard names for message
digest algorithms. Depending on which service providers are
installed, you may or may not have all of these. The JDK 1.1 includes
SHA-1 (which is the same as SHA) and MD5 but not MD2. RSA’s
paywareCrypto-J cryptography library also supports MD2.
(See http://www.rsa.com/rsa/products/jsafe/.)
Table 10-1. Message Digest Algorithms in Java 1.1
Name |
Algorithm |
---|---|
SHA-1 |
The Secure Hash Algorithm, as defined in Secure Hash Standard, NIST FIPS 180-1 (National Institute of Standards and Technology Federal Information Processing Standards Publications 180-1); produces 20-byte digests; see http://www.itl.nist.gov/div897/pubs/fip180-1.htm |
SHA |
Another name for SHA-1 |
MD2 |
RSA-MD2 as defined in RFC 1319 and RFC 1423 (RFC 1423 corrects a mistake in RFC 1319); produces 16-byte digests; suitable for use with digital signatures; see http://www.faqs.org/rfcs/rfc1319.html and http://www.faqs.org/rfcs/rfc1423.html ... |
Get Java I/O 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.