Click here to Skip to main content
15,881,709 members
Articles / Desktop Programming / MFC

FiveLoaves v1.0

Rate me:
Please Sign up or sign in to vote.
3.84/5 (10 votes)
2 Jul 20028 min read 84.7K   4.4K   49  
FiveLoaves is an Internet utility designed to meet the most common needs of internet users - primarily secure connectivity
// This file contains 3 implementations of MD5 found on the internet.

//#define USE_IMPL_1
//#define USE_IMPL_2
#define USE_IMPL_3


#ifndef MHASH_MD5_H
#define MHASH_MD5_H



#ifdef USE_IMPL_1

/* typedef a 32 bit type */
#ifdef _WIN32
	typedef __int32 UINT4;
#elif _LINUX
	#include <linux/types.h>
	typedef __u32 UINT4;
#elif __sun
	#include <sys/types.h>
	typedef uint32_t UINT4;
#elif _HPUX
	#include <sys/_inttypes.h>
	typedef uint32_t UINT4;
#else
	--ERROR--
#endif


/* Data structure for MD5 (Message Digest) computation */
typedef struct {
  UINT4 i[2];                   /* number of _bits_ handled mod 2^64 */
  UINT4 buf[4];                                    /* scratch buffer */
  unsigned char in[64];                              /* input buffer */
  unsigned char digest[16];     /* actual digest after MD5Final call */
} MD5_CTX;

void MD5Init (MD5_CTX *mdContext);
void MD5Update (MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen);
void MD5Final (MD5_CTX *mdContext);
void Hash(void* pzData, int nDataLength, unsigned char *pDest, int nBittage);

#endif // USE_IMPL_1




#ifdef USE_IMPL_2

typedef unsigned char *POINTER;
typedef unsigned char word8;

#ifdef _WIN32
	typedef __int32 word32;
#elif _LINUX
	#include <linux/types.h>
	typedef __u32 word32;
#elif __sun
	#include <sys/types.h>
	typedef uint32_t word32;
#elif _HPUX
	#include <sys/_inttypes.h>
	typedef uint32_t word32;
#else
	--ERROR--
#endif




/*
   MD5.H - header file for MD5C.C
 */

/*
   Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
   rights reserved.

   License to copy and use this software is granted provided that it
   is identified as the "RSA Data Security, Inc. MD5 Message-Digest
   Algorithm" in all material mentioning or referencing this software
   or this function.

   License is also granted to make and use derivative works provided
   that such works are identified as "derived from the RSA Data
   Security, Inc. MD5 Message-Digest Algorithm" in all material
   mentioning or referencing the derived work.

   RSA Data Security, Inc. makes no representations concerning either
   the merchantability of this software or the suitability of this
   software for any particular purpose. It is provided "as is"
   without express or implied warranty of any kind.
   These notices must be retained in any copies of any part of this
   documentation and/or software.
 */


/*
   MD5 context. 
 */
typedef struct {
	word32 state[4];			/*
								   state (ABCD) 
								 */
	word32 count[2];			/*
								   number of bits, modulo 2^64 (lsb first) 
								 */
	word8 buffer[64];			/*
								   input buffer 
								 */
} MD5_CTX;


void MD5Init (MD5_CTX *);
void MD5Update (MD5_CTX *, const unsigned char *, unsigned int);
void MD5Final (MD5_CTX *, unsigned char[16]);
void Hash(void* pzData, int nDataLength, unsigned char *pDest, int nBittage);

#endif // USE_IMPL_2


#ifdef USE_IMPL_3

#define MD5_DIGESTSIZE 16

/* UINT4 defines a four byte word */
typedef unsigned int UINT4;


/* MD5 context. */
typedef struct {
    UINT4 state[4];		/* state (ABCD) */
    UINT4 count[2];		/* number of bits, modulo 2^64 (lsb first) */
    unsigned char buffer[64];	/* input buffer */
} AP_MD5_CTX;

/*
 * Define the Magic String prefix that identifies a password as being
 * hashed using our algorithm.
 */
#define AP_MD5PW_ID "$xml1$"
#define AP_MD5PW_IDLEN 6

void ap_MD5Init(AP_MD5_CTX *context);
void ap_MD5Update(AP_MD5_CTX *context, const unsigned char *input,
			      unsigned int inputLen);
void ap_MD5Final(unsigned char digest[MD5_DIGESTSIZE],
			     AP_MD5_CTX *context);
void ap_MD5Encode(const unsigned char *password,
			      const unsigned char *salt,
			      char *result, unsigned int nbytes);
void ap_to64(char *s, unsigned long v, int n);
void Hash(void* pzData, int nDataLength, unsigned char *pDest, int nBittage);



#endif //IMPL_3



#endif // #ifndef MHASH_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
Founder United Business Technologies
United States United States
http://about.me/brian.aberle
https://www.linkedin.com/in/brianaberle
http://SyrianRue.org/Brian

Comments and Discussions