Click here to Skip to main content
15,885,953 members
Articles / Desktop Programming / MFC

Exile 1.8 - The Password Manager

Rate me:
Please Sign up or sign in to vote.
4.57/5 (51 votes)
6 Mar 20058 min read 255.2K   7.4K   111  
Yet another password manager.
/********************************************************************
	Created:	21/3/2004, 21:39
	File name: 	D:\Projects\Exile\MD5\MD5.h
	File path:	D:\Projects\Exile\MD5
	File base:	MD5
	File ext:	h
	Author:		Gogolev Anton
*********************************************************************/

#ifndef __MD5_H__
#define __MD5_H__

// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the MD5_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// MD5_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.

#ifdef MD5_EXPORTS
#define MD5_API extern "C" __declspec(dllexport)
#else
#define MD5_API extern "C" __declspec(dllimport)
#endif

BOOL WINAPI DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved);

//////////////////////////////////////////////////////////////////////////
// MD5 Types

// MD5 Word
typedef unsigned long int MD5_WORD;

// MD5 Hashing Context
typedef unsigned long int HMD5CONTEXT;

// MD5 Hash
typedef struct tagMD5HASH {
	MD5_WORD wA;
	MD5_WORD wB;
	MD5_WORD wC;
	MD5_WORD wD;
} MD5HASH, *LPMD5HASH;

// MD5 Hashing Context
typedef struct tagMD5CONTEXT {
	MD5HASH hsState;
	BYTE *pBuffer; // To buffer data which is still to be hashed
	unsigned int unBuffer; // Buffer index
	unsigned int unSize; // Total size of data hashed (in bytes)
} MD5CONTEXT, *LPMD5CONTEXT;


// Initializes MD5 internal structures
MD5_API BOOL Md5Initialize();

// Uninitializes and performs cleanup
MD5_API BOOL Md5Uninitialize();

// Acquire initialized MD5 Hashing context.
MD5_API BOOL Md5AcquireContext(HMD5CONTEXT &hMd5);

// Release MD5 Hashing context
MD5_API BOOL Md5ReleaseContext(HMD5CONTEXT &hMd5);

// Resets a hashing context so new data block can be hashed
MD5_API BOOL Md5ResetContext(HMD5CONTEXT hMd5);

// Determine if given context is a valid one
MD5_API BOOL Md5ValidContext(HMD5CONTEXT hMd5);

// Hashes a buffer (pBuffer) of a given size (sBuffer) and
// awaits either for a next part of a message, or for
// a call to Md5HashFinal()
MD5_API BOOL Md5HashBuffer(HMD5CONTEXT hMd5, BYTE *pBuffer, size_t sBuffer);

// Hashes buffered data (if any), produces a final hash
// and automatically resets hashing context.
MD5_API BOOL Md5HashFinal(HMD5CONTEXT hMd5, MD5HASH &hsMd5);

// This function should not be called under normal
// circumstances, but anyway it can be useful for some
// specific purposes. It hashes a 512-block (only!) of data
// with already defined hash value.
MD5_API BOOL Md5HashDependentBuffer(MD5_WORD *pwData, MD5HASH &hMd5);

// Calculates buffer size required for data expansion
MD5_API size_t Md5GetExpandedBufferSize(size_t sSize);

// Expands data buffer pointed by pvData. Buffer must be sTotal bytes long
// and must contain sSgSize bytes of significant data. Remaining bytes
// will be by Md5ExpandData()
MD5_API BOOL Md5ExpandData(void *pvData, size_t sSgSize, size_t sTotal);

// Hashes message of nBlocks 512-bit blocks pointed by pwData.
MD5_API BOOL Md5HashData(MD5_WORD *pwData, UINT nBlocks, MD5HASH &hMd5);

// Tests if two hashes are equal
MD5_API BOOL Md5EqualHashes(MD5HASH hsMd5A, MD5HASH hsMd5B);

#endif //__MD5_H__

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Russian Federation Russian Federation
I'll think about it later on...

Comments and Discussions