Jump to content

MD5 Hash

- - - - -

  • Please log in to reply
31 replies to this topic

#1
Termana

Termana

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,057 posts
In this tutorial I will show you how to get an MD5 Hash of a file or a string.

1. Start a new Console Application project in your IDE

2. Download the file I have attached, unzip the files somewhere, and place them in the same folder as your project. Make sure you add them to the projects file list.

3. You will need to include the md5wrapper header:

#include "md5wrapper.h"


4. In your main function, put in this code, I have commented about what things do:

// This will allow us to access the md5wrapper class.

md5wrapper md5;

// This will store the md5 hash of a file called test.txt in a string hash1

std::string hash1 = md5.getHashFromFile("test.txt");

// This will store the md5 hash of some text into a string hash2

std::string hash2 = md5.getHashFromString("Hello World");

// This will print, the hash from the file and from the string

std::cout << hash1 << std::endl; << hash2 std::endl;

system("PAUSE"); // Remove if your using Linux.

return 0;


5. Edit the above code to make it do what you want, I have tried to make it as obvious as to how you can use it properly.

6. Enjoy. And +rep me :P lol

Attached Files

  • Attached File  md5.zip   6.03K   975 downloads

Interested in participating in community events?
Want to harness your programming skill and turn it into absolute prowess?
Come join our programming events!


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Can you offer some commentary on how the MD5 code works and what it does?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
OrhanC1

OrhanC1

    Newbie

  • Members
  • Pip
  • 3 posts

WingedPanther said:

Can you offer some commentary on how the MD5 code works and what it does?

Hi! I don't mean to come across as rude and I'm genuinely asking this as a question i would like answered but could you not just read the header?

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Having implemented a modified MD5 hash, I know what it does, but would like to see someone explain it.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
It's a shame you are using inbuilt functions instead of using your own algorithm. But what the heck, +rep.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#6
Monkeyjoe

Monkeyjoe

    Newbie

  • Members
  • Pip
  • 1 posts
Thanks

#7
Kennylap

Kennylap

    Newbie

  • Members
  • Pip
  • 1 posts
Oh! Thanks, i'm searching for this for sometime..
Really appreciated ;)

#8
Phoenixz

Phoenixz

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 256 posts
Edit: NVM I think I got it now, but what practical uses are there for this, may you explain? :)

Edited by Phoenixz, 24 January 2009 - 10:41 AM.

Posted Image

#9
k3n

k3n

    Newbie

  • Members
  • Pip
  • 1 posts
thanks a lot

#10
chili5

chili5

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 7,247 posts
  • Programming Language:Java, C#, PHP
  • Learning:C, C++, C#, PHP, Transact-SQL, Assembly, Scheme
So what does your code do?

You didn't really explain what it does? What does the md5 function do?

Why do we need access to the md5wrapper?

#11
Mr_Dark

Mr_Dark

    Newbie

  • Members
  • Pip
  • 1 posts
Nice class, helped my a lot.

#12
Thundergod

Thundergod

    Newbie

  • Members
  • Pip
  • 1 posts
Nice, ty.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users