- Message Digest MD5 and SHA

This section describes 2 popular message digest algorithm, MD5 and SHA, implemented in JDK as part of the JCA (Java Cryptography Architecture) package.

What Is Message Digest? Message digest is a one-way hash function that takes arbitrary-sized data and outputs a fixed-length hash value.

Known message digest algorithms are:

Message digest is supported in JDK as part of the JCA (Java Cryptography Architecture) package, which has been included in JDK since 1.1:

In JCA, the class is an abstract class providing a link to implementation classes of message digest algorithms provided by various security package providers. Major methods in the MessageDigest class are:

getInstance() - Returns a message digest object of the specified algorithm from the implementation of the specified provider. If provider is not specified, the default implementation is used. This is a static method.

update() - Adds more data to the current message digest object for processing.

digest() - Returns the digest data of the input data processed so far in the current message digest object. It also removes the input data received in the object.

getAlgorithm() - Returns the algorithm name of the current message digest object.

getProvider() - Returns the provider as a provider object of the current message digest object.

See the next section for a sample program of using the MessageDigest class.

Table of Contents

 About This JDK Tutorial Book

 JDK (Java Development Kit)

 Java Date-Time API

 Date, Time and Calendar Classes

 Date and Time Object and String Conversion

 Number Object and Numeric String Conversion

 Locales, Localization Methods and Resource Bundles

 Calling and Importing Classes Defined in Unnamed Packages

 HashSet, Vector, HashMap and Collection Classes

 Character Set Encoding Classes and Methods

 Character Set Encoding Maps

 Encoding Conversion Programs for Encoded Text Files

 Java Logging

 Socket Network Communication

 Datagram Network Communication

 DOM (Document Object Model) - API for XML Files

 SAX (Simple API for XML)

 DTD (Document Type Definition) - XML Validation

 XSD (XML Schema Definition) - XML Validation

 XSL (Extensible Stylesheet Language)

Message Digest Algorithm Implementations in JDK - Message Digest MD5 and SHA - Message Digest Sample Program

 Comparing Message Digest Output of MD5 and SHA

 Private key and Public Key Pair Generation

 PKCS#8/X.509 Private/Public Encoding Standards

 Digital Signature Algorithm and Sample Program

 "keytool" Commands and "keystore" Files

 KeyStore and Certificate Classes

 Secret Key Generation and Management

 Cipher - Encryption and Decryption

 The SSL (Secure Socket Layer) Protocol

 SSL Socket Communication Testing Programs

 SSL Client Authentication

 HTTPS (Hypertext Transfer Protocol Secure)

 Outdated Tutorials


 Full Version in PDF/EPUB