MD5
Implements the Message-Digest algorithm 5.
You're viewing an older version of this page (#916). View the current version.
Interface
#include <codecogs/computing/security/md5.h>
using namespace Computing::Security;
inline uint32_t md5AddRotate(uint32_t value, uint32_t B, char shiftCount)inline uint32_t md5F(uint32_t A, uint32_t B, uint32_t C, uint32_t D, uint32_t blockItem, char shiftCount, uint32_t sineValue)inline uint32_t md5G(uint32_t A, uint32_t B, uint32_t C, uint32_t D, uint32_t blockItem, char shiftCount, uint32_t sineValue)inline uint32_t md5H(uint32_t A, uint32_t B, uint32_t C, uint32_t D, uint32_t blockItem, char shiftCount, uint32_t sineValue)inline uint32_t md5I(uint32_t A, uint32_t B, uint32_t C, uint32_t D, uint32_t blockItem, char shiftCount, uint32_t sineValue)inline std::string md5(std::string &str)
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 $c_0$, $c_1$, ..., $c_{63}$ defined through:
where $\lfloor \cdot \rfloor$ 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;
}Output
Input: somewhere over the rainbow
MD5: fe6acc5bea48d66ac6baa60ff73f6d62References
- 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
FUNCTION
md5AddRotate
FUNCTION
md5F
FUNCTION
md5G
FUNCTION
md5H
FUNCTION
md5I
FUNCTION
md5
This function generates the unique MD5 code corresponding to the given string, in the form of a 32 digits hexadecimal number.
For example, to obtain the MD5 code of the string "Hello World", you would write something similar to:
std::string md5Code = Computing::Security::Hash::md5("Hello World");
Parameters
Returns
Interactive Calculator
Computing…
Set a range above first to export a graph.