Is it possible to identify if files are the same if they have the same md5 code? Erm, just came to mind, how do you calculate the md5 of a file?
Is it possible to identify if files are the same if they have the same md5 code? Erm, just came to mind, how do you calculate the md5 of a file?
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
ok, I took a look at
http://userpages.umbc.edu/~mabzug1/cs/md5/md5.html
And I'm trying to get the Cpp code to work, I get tons of errors and not sure why. All I do is include the md5.cc and md5.hh in my main.cpp and compile and I get a shyteload of errors.
Visual C++ .Net 2k3
Windows XP
Last edited by neandrake; 12-02-2003 at 08:57 AM.
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
Ok so I found in MSDN this:
http://msdn.microsoft.com/library/de...ClassTopic.asp
(imagine life without copy & paste)
I'm a little confused though; I've never used namespaces before. How do I include the System.Security.Cryptography namespace?
namespace System.Security.Cryptography
doesn't work.
Also, will I need to add the mscorlib.dll file in my project somehow?
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
> Is it possible to identify if files are the same if they have the same md5 code?
No, that just tells you that the files are probably the same.
The probablility is however pretty high. md5 is a 128 bit hash, and the probability that two different files have the same md5 hash is 1 in pow(2,128)
> and I get a shyteload of errors.
Well posting a few of them may be helpful to the rest of us.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Well, I kinda dumped that code and found out that there are functions already in Security namespace, but I still get an error with this code:Originally posted by Salem
>> and I get a shyteload of errors.
Well posting a few of them may be helpful to the rest of us.
Code:#define WIN32_LEAN_AND_MEAN #include <windows.h> #using <mscorlib.dll> using namespace System; using namespace System::IO; using namespace System::Security; using namespace System::Security::Cryptography; INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPInst, LPSTR lpszCmdLine, INT iCmdShow) { MSG msgMain; while(GetMessage(&msgMain, 0, 0, 0)) { TranslateMessage(&msgMain); DispatchMessage(&msgMain); } MD5 *str = new MD5CryptoServiceProvider(); return (int)msgMain.wParam; }Code:Error: main.cpp(4): fatal error C1190: managed targeted code requires '#using <mscorlib.dll>' and '/clr' option
Last edited by neandrake; 12-02-2003 at 10:12 AM.
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
Ok so I changed the project option to Using Managed Extentions or something like that. No errors now.
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
damnit, I can't get that to work, never used namespaces before, too much new stuff, back to using the example c++ code given.
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
Ok, back to using the example code, all I did was include md5.h and md5.cpp into my project.
That's only a few of the errors I get. From a glance, all errors are in md5.hCode:[i]Errors:[/] md5.h(52): error C2061: syntax error : identifier 'istream' md5.h(54): error C2061: syntax error : identifier 'ifstream' md5.h(54): error C2535: 'void MD5::update(void)' : member function already defined or declared md5.h(60): error C2143: syntax error : missing ')' before '&'
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
How about sticking to regular C++ before trying to getting yourself horribly tangled in all that vs.net "managed" stuff?
> md5.h(52): error C2061: syntax error : identifier 'istream'
Perhaps a simple C++
using namespace std;
placed at the start of md5.h
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Yea, that's why I stopped using the .net shyte. I tried adding the namespace, and it didn't change anything. Could you try the same thing I did? Download the file, extract md5.hh and md5.cc and include them in your project. Then for main.cpp all I did was have a WinMain() function with nothing in it (except the message handling).
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
Also, you may want to move to SHA-1 or RIPEMD-160. MD5 has been demonstrated to be weaker against collisions in some sense, which is why most cryptographic systems are supporting MD5 only for backwards compatibility.Originally posted by neandrake
Is it possible to identify if files are the same if they have the same md5 code? Erm, just came to mind, how do you calculate the md5 of a file?
In other words, SHA-1 and RIPEMD-160 are better in that collisions (two different messages producing the same digest) seems to be less. At least that is the current thought.
You might try this library:
http://www.eskimo.com/~weidai/cryptlib.html
of course, it may be overkill.
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.
Very overkill
There aren't any sites that show how to implement these hashes in c++? Maybe in another language that can be easily converted to c++
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.