MD5
Implements the Message-Digest algorithm 5.
Controller: CodeCogs
Contents
Interface
C++
Overview
This module implements the MD5 (Message-Digest algorithm 5) algorithm, which is a 128-bit valued hash function designed by Ron Rivest in 1991. Its main application is to check the integrity of data, but it can also be used in conjunction with cryptosystems like RSA. The idea of the algorithm is to encode the input message using four 32-bit registers and by going through a series of bitwise operations, based on the following four functions: The algorithm also uses a number of 64 constants , , ..., defined through: where denotes the floor function. The following example displays the MD5 code for the string "somewhere over the rainbow".Example 1
#include <iostream> #include <codecogs/computing/security/md5.h> int main() { std::string data = "somewhere over the rainbow"; std::cout << "Input: " << data << std::endl; std::cout << " MD5: " << Computing::Security::md5(data) << std::endl; return 0; }
OutputInput: somewhere over the rainbow MD5: fe6acc5bea48d66ac6baa60ff73f6d62
Authors
- Lucian Bentea (July 2009)
References
- The MD5 Message-Digest Algorithm (RFC1321), http://tools.ietf.org/html/rfc1321
- The description of the MD5 algorithm on Wikipedia, http://en.wikipedia.org/wiki/MD5
- Free online MD5 hash calculator based on PHP, http://md5-hash-online.waraxe.us
Md5
std::stringmd5( | std::string& | str | )[inline] |
std::string md5Code = Computing::Security::Hash::md5("Hello World");
Parameters
str the string to be hashed
Returns
- the MD5 code corresponding to str, as a 32 digits hexadecimal number stored as a string
Source Code
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.