I may have requested this before, but I was wondering if it was possible to include MD4 hash calculation? I use emule most of the time and that uses the format:
ed2k://|file|FILENAME|FILESIZEBYTES|MD4HASHHERE|/
There are some open source programs on emule-project.net in C code on hashing ed2k links under downloads.
I think this is the MD4 hashing part:
class CAddFileThread : public CWinThread
{
DECLARE_DYNCREATE(CAddFileThread)
protected:
CAddFileThread();
public:
virtual BOOL InitInstance();
virtual int Run();
void SetValues(LPCTSTR directory, LPCTSTR filename);
private:
CString m_strDirectory;
CString m_strFilename;
};
// constants for MD4Transform
#define S11 3
#define S12 7
#define S13 11
#define S14 19
#define S21 3
#define S22 5
#define S23 9
#define S24 13
#define S31 3
#define S32 9
#define S33 11
#define S34 15
// basic MD4 functions
#define MD4_F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define MD4_G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
#define MD4_H(x, y, z) ((x) ^ (y) ^ (z))
// rotates x left n bits
// 15-April-2003 Sony: use MSVC intrinsic to save a few cycles
#ifdef _MSC_VER
#pragma intrinsic(_rotl)
#define MD4_ROTATE_LEFT(x, n) _rotl((x), (n))
#else
#define MD4_ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
#endif
// partial transformations
#define MD4_FF(a, b, c, d, x, s) \
{ \
(a) += MD4_F((b), (c), (d)) + (x); \
(a) = MD4_ROTATE_LEFT((a), (s)); \
}
#define MD4_GG(a, b, c, d, x, s) \
{ \
(a) += MD4_G((b), (c), (d)) + (x) + (uint32)0x5A827999; \
(a) = MD4_ROTATE_LEFT((a), (s)); \
}
#define MD4_HH(a, b, c, d, x, s) \
{ \
(a) += MD4_H((b), (c), (d)) + (x) + (uint32)0x6ED9EBA1; \
(a) = MD4_ROTATE_LEFT((a), (s)); \
}
static void MD4Transform(uint32 Hash[4], uint32 x[16]);