944,089 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1232
  • C++ RSS
Aug 12th, 2006
0

linking problems

Expand Post »
md5.cpp
C++ Syntax (Toggle Plain Text)
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <string>
  4. #include <stdio.h>
  5. #include "md5.h"
  6. using namespace std;
  7. char* szString = "Some string you want to generate an MD5 key for.";
  8. int main(int argc, char *argv[])
  9. {
  10. char* sString = MD5String(szString);
  11. cout << "Some string you want to generate an MD5 key for." << "MD5 Output: " << sString;
  12. system("PAUSE");
  13. return EXIT_SUCCESS;
  14. }

md5.h
C++ Syntax (Toggle Plain Text)
  1. typedef unsigned int uint4;
  2. typedef unsigned short int uint2;
  3. typedef unsigned char uchar;
  4. char* PrintMD5(uchar md5Digest[16]);
  5. char* MD5String(char* szString);
  6. char* MD5File(char* szFilename);
  7. class md5
  8. {
  9. public:
  10. md5() { Init(); }
  11. void Init();
  12. void Update(uchar* chInput, uint4 nInputLen);
  13. void Finalize();
  14. uchar* Digest() { return m_Digest; }
  15. private:
  16. void Transform(uchar* block);
  17. void Encode(uchar* dest, uint4* src, uint4 nLength);
  18. void Decode(uint4* dest, uchar* src, uint4 nLength);
  19. inline uint4 rotate_left(uint4 x, uint4 n)
  20. { return ((x << n) | (x >> (32-n))); }
  21. inline uint4 F(uint4 x, uint4 y, uint4 z)
  22. { return ((x & y) | (~x & z)); }
  23. inline uint4 G(uint4 x, uint4 y, uint4 z)
  24. { return ((x & z) | (y & ~z)); }
  25. inline uint4 H(uint4 x, uint4 y, uint4 z)
  26. { return (x ^ y ^ z); }
  27. inline uint4 I(uint4 x, uint4 y, uint4 z)
  28. { return (y ^ (x | ~z)); }
  29. inline void FF(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
  30. { a += F(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
  31. inline void GG(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
  32. { a += G(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
  33. inline void HH(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
  34. { a += H(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
  35. inline void II(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
  36. { a += I(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
  37. private:
  38. uint4 m_State[4];
  39. uint4 m_Count[2];
  40. uchar m_Buffer[64];
  41. uchar m_Digest[16];
  42. uchar m_Finalized;
  43. };

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

Help please
Last edited by Ripiz; Aug 12th, 2006 at 12:06 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Ripiz is offline Offline
2 posts
since Aug 2006
Aug 12th, 2006
0

Re: linking problems

Where and how didi you define your MD5String function?
Reputation Points: 55
Solved Threads: 6
Junior Poster
Micko is offline Offline
148 posts
since Aug 2005
Aug 12th, 2006
0

Re: linking problems

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Ripiz is offline Offline
2 posts
since Aug 2006
Aug 12th, 2006
0

Re: linking problems

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.
Super Moderator
Featured Poster
Reputation Points: 3241
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,873 posts
since Jun 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Deleting this pointer
Next Thread in C++ Forum Timeline: WinSock problems.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC