CMD5 Class ReferenceCalculates an MD5 Hash.
More...
#include <md5.h>
List of all members.
|
Public Member Functions |
| void | Random (LPVOID buf=NULL, DWORD size=0) |
| | Creates a random hash.
|
| BOOL | HashToString (LPSTR str, DWORD size) |
| | Convers the hash to a string.
|
| BOOL | StringToHash (LPCTSTR str) |
| | Converts a string to a hash.
|
| BOOL | TransformFile (LPCTSTR pFile) |
| | Performs MD5 hash on a file.
|
| BOOL | Transform (LPVOID buf, DWORD size) |
| | Updates the MD5 hash with the specified data.
|
| BOOL | Transform (LPBYTE buf, DWORD size) |
| | Updates the MD5 hash with the specified data.
|
| BOOL | Transform (LPCTSTR pString) |
| | Updates the MD5 hash with the specified string.
|
| BOOL | End () |
| | Completes the hash.
|
| void | ByteReverse (LPBYTE buf, DWORD longs) |
| | Reverses the bytes in buf.
|
|
| CMD5 () |
| | Default Constructor.
|
|
LPBYTE | GetDigest () |
| | Returns a pointer to the digest buffer.
|
|
LPBYTE | GetHash () |
| | Returns a pointer to the hash buffer.
|
|
DWORD | GetHashLen () |
| | Returns the length of the hash, currently 16 bytes.
|
|
void | Init () |
| | Initializes the hash variables.
|
Static Public Member Functions |
| static void | CalcOffsetMask (DWORD bit, LPDWORD offset, LPBYTE mask) |
| | Calculates offset mask for bit.
|
| static DWORD | GetBit (LPBYTE buf, DWORD bit) |
| | Gets the value of the specified bit.
|
| static DWORD | GetValue (LPBYTE buf, DWORD bitoff, DWORD bits) |
| | Returns the value of the specified bit range.
|
| static BOOL | HashToString (LPBYTE hash, DWORD hashbits, LPSTR str, DWORD size) |
| | Converts a hash to a string.
|
| static void | SetBit (LPBYTE buf, DWORD bit, DWORD set) |
| | Sets the specified bit.
|
| static DWORD | SetValue (LPBYTE buf, DWORD bitoff, DWORD bits, DWORD value) |
| | Sets the value of a bit sequence.
|
| static BOOL | StringToHash (LPBYTE hash, DWORD hashbits, LPCTSTR str) |
| | Converts a string into a hash.
|
| static void | Transform (DWORD *hash, const DWORD *data) |
| | Updates hash with data.
|
Public Attributes |
|
DWORD | m_digest [4] |
| | MD5 digest.
|
|
DWORD | m_hash [4] |
| | MD5 hash.
|
|
BYTE | m_buf [64] |
| | MD5 input data buffer.
|
|
DWORD | m_total |
| | Bytes in m_buf.
|
Protected Member Functions |
| void | vTransform (const DWORD *data) |
| | Updates hash with 64 bytes of input data.
|
Detailed Description
Calculates an MD5 Hash.
Calculates an MD5 hash. Also includes a few support functions.
Member Function Documentation
| void CMD5::ByteReverse |
( |
LPBYTE |
buf, |
|
|
DWORD |
longs |
|
) |
|
|
|
|
Reverses the bytes in buf.
- Parameters:
-
| [in,out] | buf | - Buffer pointer |
| [in] | longs | - Number of bytes to reverse |
- Returns:
- See also:
|
| void CMD5::CalcOffsetMask |
( |
DWORD |
bit, |
|
|
LPDWORD |
offset, |
|
|
LPBYTE |
mask |
|
) |
[static] |
|
|
|
Calculates offset mask for bit.
- Parameters:
-
| [in] | bit | - Bit index |
| [out] | offset | - Byte offset |
| [out] | mask | - Bit mask |
To check say the 125th bit in a buffer
BYTE buf[ 100 ];
BYTE ucMask;
DWORD dwOffset;
CalcOffsetMask( 125, &dwOffset, &ucMask );
if ( buf[ dwOffset ] & ucMask )
;
else ;
|
|
|
Completes the hash.
- Returns:
- Non-zero if success
- See also:
|
| DWORD CMD5::GetBit |
( |
LPBYTE |
buf, |
|
|
DWORD |
bit |
|
) |
[static] |
|
|
|
Gets the value of the specified bit.
- Parameters:
-
| [in] | buf | - Pointer to bit buffer |
| [in] | bit | - Bit offset |
- Returns:
- Value of specified bit, 0 or 1
- See also:
|
| DWORD CMD5::GetValue |
( |
LPBYTE |
buf, |
|
|
DWORD |
bitoff, |
|
|
DWORD |
bits |
|
) |
[static] |
|
|
|
Returns the value of the specified bit range.
- Parameters:
-
| [in] | buf | - Bit buffer |
| [in] | bitoff | - bit offset |
| [in] | bits | - Number of bits |
- Returns:
- Value of specfied bit range
- See also:
|
| BOOL CMD5::HashToString |
( |
LPBYTE |
hash, |
|
|
DWORD |
hashbits, |
|
|
LPSTR |
str, |
|
|
DWORD |
size |
|
) |
[static] |
|
|
|
Converts a hash to a string.
- Parameters:
-
| [in] | hash | - Hash buffer |
| [in] | hashbits | - Number of bits in the hash |
| [out] | str | - Receives the hash string |
| [in] | size | - Size of the buffer in str |
- Returns:
- Non-zero on success
- See also:
|
| BOOL CMD5::HashToString |
( |
LPSTR |
str, |
|
|
DWORD |
size |
|
) |
[inline] |
|
|
|
Convers the hash to a string.
- Parameters:
-
| [out] | str | - Receives the string |
| [in] | size | - Size of the buffer in str |
- Returns:
- Non-zero if success
- See also:
- StringToHash()
|
| void CMD5::Random |
( |
LPVOID |
buf = NULL, |
|
|
DWORD |
size = 0 |
|
) |
|
|
|
|
Creates a random hash.
- Parameters:
-
| [in] | buf | - Seed buffer |
| [in] | size | - Number of bytes in buf |
|
| void CMD5::SetBit |
( |
LPBYTE |
buf, |
|
|
DWORD |
bit, |
|
|
DWORD |
set |
|
) |
[static] |
|
|
|
Sets the specified bit.
- Parameters:
-
| [out] | buf | - Buffer containing bit |
| [in] | bit | - Bit index |
| [in] | set | - Bit state, zero or non-zero |
- Returns:
- See also:
|
| DWORD CMD5::SetValue |
( |
LPBYTE |
buf, |
|
|
DWORD |
bitoff, |
|
|
DWORD |
bits, |
|
|
DWORD |
value |
|
) |
[static] |
|
|
|
Sets the value of a bit sequence.
- Parameters:
-
| [in] | buf | - Buffer containing bits |
| [in] | bitoff | - Bit sequence offset |
| [in] | bits | - Number of bits in sequence |
| [in] | value | - Value of bit sequences |
Since value is a DWORD, a maximum of 32 bits can be set at once.
- Returns:
- Contents of value
- See also:
|
| BOOL CMD5::StringToHash |
( |
LPBYTE |
hash, |
|
|
DWORD |
hashbits, |
|
|
LPCTSTR |
str |
|
) |
[static] |
|
|
|
Converts a string into a hash.
- Parameters:
-
| [in] | hash | - Hash data |
| [in] | hashbits | - Number of bits in the hash |
| [out] | str | - Receives the string representation |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CMD5::StringToHash |
( |
LPCTSTR |
str |
) |
[inline] |
|
|
|
Converts a string to a hash.
- Parameters:
-
| [in] | str | - String representation of hash |
- Returns:
- Non-zero if success
- See also:
- HashToString()
|
| void CMD5::Transform |
( |
DWORD * |
hash, |
|
|
const DWORD * |
data |
|
) |
[static] |
|
|
|
Updates hash with data.
- Parameters:
-
| [in,out] | hash | - Hash |
| [in] | data | - 64 bytes of data |
- Returns:
- See also:
|
| BOOL CMD5::Transform |
( |
LPCTSTR |
pString |
) |
|
|
|
|
Updates the MD5 hash with the specified string.
- Parameters:
-
| [in] | pString | - String to hash |
- Returns:
- Non-zero if success
- See also:
|
| BOOL CMD5::Transform |
( |
LPBYTE |
buf, |
|
|
DWORD |
size |
|
) |
|
|
|
|
Updates the MD5 hash with the specified data.
- Parameters:
-
| [in] | buf | - Pointer to data |
| [in] | size | - Number of bytes in buf |
If you intend to make multiple calls to this function, the first calls must be 64 bytes in length. The last call may be less than 64 bytes.
No more calls to this functions after a block size of less than 64 bytes.
- Returns:
- Non-zero if success
- See also:
|
| BOOL CMD5::Transform |
( |
LPVOID |
buf, |
|
|
DWORD |
size |
|
) |
[inline] |
|
|
|
Updates the MD5 hash with the specified data.
- Parameters:
-
| [in] | buf | - Pointer to data |
| [in] | size | - Number of bytes in buf |
If you intend to make multiple calls to this function, the first calls must be 64 bytes in length. The last call may be less than 64 bytes.
No more calls to this functions after a block size of less than 64 bytes.
- Returns:
- Non-zero if success
- See also:
|
| BOOL CMD5::TransformFile |
( |
LPCTSTR |
pFile |
) |
|
|
|
|
Performs MD5 hash on a file.
- Parameters:
-
| [in] | pFile | - File to hash |
- Returns:
- Non-zero if success
- See also:
|
| void CMD5::vTransform |
( |
const DWORD * |
data |
) |
[inline, protected] |
|
|
|
Updates hash with 64 bytes of input data.
- Parameters:
-
| [in] | data | - Buffer containing 64 bytes of data |
|
The documentation for this class was generated from the following files:
|