What is FileDigest?
FileDigest is a cryptographic product useful for generating digital signatures for files or typed text (strings) applying one of the following message-digesting methods:
SHA256, SHA384 and SHA512).
Short Presentation of the Algorithms
MD5 is part of the family of message-digest algorithms
MD5 developed by
R. Rivest in collaboration with
MIT Laboratory for Computer Science and
RSA Data Security, Inc. The
MD5 algorithm is an extension of the
MD4 message-digest algorithm, slightly slower than
MD4, but on the other side more secure. All three algorithms take a message of arbitrary length and produce a 128-bit message digest.
RIPEMD160 are upgrades to
RIPEMD was developed in the framework of the
RACE Integrity Primitives Evaluation, 1988-1992). 128-bit hash results are considered to not offer anymore sufficient protection, and applications using 128-bit hash functions should consider upgrading to 160-bit hash functions.
RIPEMD160 is a 160-bit cryptographic hash function, designed by
Antoon Bosselaers, and
Bart Preneel. It is intended to be used as a secure replacement for the 128-bit hash functions
Secure Hash Algorithm (
SHA) algorithm specified in the
Secure Hash Standard (
SHS), was developed by
NIST and published as a federal information processing standard (
FIPS PUB 180).
SHA-1 was a revision to
SHA that was published in 1994. The revision corrected an unpublished flaw in
SHA. Its design is very similar to the
MD4 family of hash functions developed by
R. Rivest. The
SHA-1 algorithm takes a message of any length and produces a 160-bit message digest. The algorithm is slightly slower than
MD5, but the larger message digest makes it more secure against brute-force collision and inversion attacks. Motivated by the recent
NIST proposed replacements of the
SHA-1 hash algorithm with the
SHA-512, together known as
SHA-2, algorithms considered to provide a level of collision resistance equivalent to the security of each
AES key sizes. The message digest length for
SHA-1 is 160 bits (20 bytes). The message digest lengths for the new
SHA-512 are respectively 256 bits (32 bytes), 384 bits (48 bytes), 512 bits (64 bytes). The increase in size is significant, making difficult to break the new algorithms.
The table bellow is summarizing the key features of the
FileDigest's implemented message-digest algorithms:
|Method||Digest Length (bytes)||Security|
All the algorithms are implemented using a common interface,
IMessageDigest, which is partially presented bellow:
virtual void AddData(char const* pcData, int iDataLength) = 0;
virtual void FinalDigest(char* pcDigest) = 0;
virtual void Reset() = 0;
void DigestFile(string const& rostrFileIn, char* pcDigest);
virtual void Transform() = 0;
Notice that all the classes implementing the
IMessageDigest interface have to overdide the pure virtual member functions:
DigestFile(), while the function
DigestFile() is general and already implemented.
Reset() is used to prepare the same object for a new message-digesting operation.
AddData() is adding a new buffer of data to the current message-digesting operation.
FinalDigest() is concluding any current message-digesting operation.
DigestFile() is used for digesting an entire file.
If you want to use the implemented algorithms in your own project, you need to copy the following files from the
FileDigest project, and integrate them in your project:
DoubleBuffering.cpp. The use is easy, as is demonstrated by the following code snippet:
Notice that the result is a binary array of characters, so it cannot be manipulated as usual 0 terminated strings of characters.
Using the FileDigest program
Help menu of the
FileDigest program is not implemented right now. The information given in the following paragraphs can be considered as a small
There are two modes of operations of
FileDigest selectable from the
String Mode and
How to use FileDigest in String Mode
The message-digest method can be selected from the
Method Group Combo Box one of the values:
SHA256, SHA384, SHA512).
The text (string) can to be introduced in one of the
Edit Boxes in the
String Group, depending on the selected mode:
Hex. In the
Hex Edit Box only hexadecimal characters (0-9,A-F) can be introduced, if you try to type any other characters an error signaling beep will be generated. Also if you try to copy a text from the
Clipboard it will be first verified if is in hexa format (restricted to the set of hexa characters and even in length). These restrictions apply to all the other
Hex Edit Boxes used in
After pressing the
String Digest Button the result will be displayed in the
Digest Result (string) Edit Box as a string of characters and in the
Digest Result (hexadecimal) Edit Box as a hexadecimal format string.
How to use FileDigest in File mode
The message-digest method is selected similarly as in the
File can be typed in the
File Edit Box, or browsed from the browsing button located near the
File Edit Box. By pressing the
File Digest button the result will be displayed in
Digest Result (string) Edit Box as a string of characters and in
Digest Result (hexadecimal) Edit Box as a string in hexadecimal format. The result can be saved in a file (default extension
.fdg) from the
Save As... Button.
When you need to check a digital signature against a file, you can load the digital signature from a digest file using the
Load... Button, and then check against the file selected in the
File Edit Box using the
FileDigest.zip attached to this article is including the source code of the presented message-digest algorithms and
FileDigest program. I am interested in any opinions and new ideas about this implementation.
Typical Disclaimer: This Article and attached code are Copyright (C) 2003 by George Anescu. You have the right to use and distribute the article's content and code in any way you see fit as long as this paragraph is included with the distribution. No warranties or claims are made as to the validity of the information and code contained herein, so use it at your own risk.