954,190 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

linking problems

md5.cpp

#include <cstdlib>
#include <iostream>
#include <string>
#include <stdio.h>
#include "md5.h"
using namespace std;
char* szString = "Some string you want to generate an MD5 key for.";
int main(int argc, char *argv[])
{
    char* sString = MD5String(szString);
    cout << "Some string you want to generate an MD5 key for." << "MD5 Output: " << sString;
    system("PAUSE");
    return EXIT_SUCCESS;
}


md5.h

typedef unsigned       int uint4;
typedef unsigned short int uint2;
typedef unsigned      char uchar;
char* PrintMD5(uchar md5Digest[16]);
char* MD5String(char* szString);
char* MD5File(char* szFilename);
class md5
{
public:
 md5() { Init(); }
 void Init();
 void Update(uchar* chInput, uint4 nInputLen);
 void Finalize();
 uchar* Digest() { return m_Digest; }
private:
 void Transform(uchar* block);
 void Encode(uchar* dest, uint4* src, uint4 nLength);
 void Decode(uint4* dest, uchar* src, uint4 nLength);
 inline uint4 rotate_left(uint4 x, uint4 n)
                  { return ((x << n) | (x >> (32-n))); }
 inline uint4 F(uint4 x, uint4 y, uint4 z)
                  { return ((x & y) | (~x & z)); }
 inline  uint4 G(uint4 x, uint4 y, uint4 z)
                  { return ((x & z) | (y & ~z)); }
 inline  uint4 H(uint4 x, uint4 y, uint4 z)
                  { return (x ^ y ^ z); }
 inline  uint4 I(uint4 x, uint4 y, uint4 z)
                  { return (y ^ (x | ~z)); }
 inline void FF(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
                  { a += F(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
 inline void GG(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
                     { a += G(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
 inline void HH(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
                     { a += H(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
 inline void II(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
                     { a += I(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
private:
 uint4  m_State[4];
 uint4  m_Count[2];
 uchar  m_Buffer[64];
 uchar  m_Digest[16];
 uchar  m_Finalized;
};


I get this error
[Linker error] undefined reference to `MD5String(char*)'

Help please

Ripiz
Newbie Poster
2 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 

Where and how didi you define your MD5String function?

Micko
Junior Poster
148 posts since Aug 2005
Reputation Points: 55
Solved Threads: 6
 

I don't know C++ language, just learning now, copied this code from some old post(I think), how to define it?

Thanks for your help

Ripiz
Newbie Poster
2 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 

It would be really better if you start from the basics rather than jumping in the middle of nowhere. If you dont understand the code there is no point in makin it run.

Still if you want the working code, you can try a new implementation of the MD5 algorithm HERE.

Hope it helped,
Bye.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 733
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You