11.1.2 The MD5 Digest: Package Digest::MD5
11.1.2 The MD5 Digest: Package Digest::MD5
The MD5 message digest algorithm was developed by Rivest at MIT. MD5 takes as input a message of arbitrary length and produces as output an 128-bit message digest. The input can be a string of arbitrary length, or it can be the contents of a whole file. It can be a text file or a binary file such as an image. The input is processed in 512-bit blocks at a time. There is no limit to the size of the message. Irrespective of how large the message is, whether a single bit or tens of millions of bits, the digest produced is always of the same length. If the input is large in size, it is broken into smaller blocks that are processed one at a time. The digest obtained from the previous blocks cumulatively affects the digest obtained in the next round of computation, i.e., when the next block of the message is processed.
The MD5 algorithm has the property that every bit of the hash code is a function of every bit in the input. Whether it is a single bit, a small string or a large file, the message is considered in terms of blocks of bits for the hash computation. Various computations are done on the blocks of bits. Because of the design of the underlying mathematical functions, it is unlikely that two messages chosen at random, even if they exhibit similar regularities, will have the same hash code. According to Rivest, MD5 is as strong as an 128-bit hash code can be.
MD5 was one of the most widely used hash algorithms till recently. Researchers are always trying to find weaknesses of hash algorithms in order to break them. There are two approaches researchers use to break the code: brute-force technique and more intelligent techniques called cryptanalytic techniques. In a brute-force technique, one tries all possibilities. In cryptanalytic techniques, one uses mathematically based techniques to break the code. The usage of MD5 has gone down in the last few years because it has been shown that brute-force and cryptanalytic attacks can possibly be successful against it. MD5 is now considered breakable. Therefore, the research community has come up with several newer hash functions to replace MD5. Some of the new techniques are SHA-1, RIPEMD-160, and Tiger. However, before discussing any of these newer techniques, we will discuss two older techniques, MD4 and MD2.
We will now present a few programs that use MD5 digest. If we want to use one of the other digest algorithms, the programming are quite similar.
