# What is this MD5 encryption?



## cassamine (Nov 22, 2002)

What is this MD5 encryption?
what are those Hashes?
where can i learn about implementing it in my softwares for storing passwords in database?

Need help

cassamine


----------



## CyBerAliEn (Nov 25, 2001)

I may not be the best for answering this question, but as you mentioned, it is used for things like passwords.

When you MD5 something, you cannot "decrypt" it and get back what you entered. It is a one way thing.

If you have like a username/password in a database/file/etc, you would simply do something like:


```
<?php

//Say a user is "signing" up or something.  They enter their
//password and other info into a form, and then it is processed.

//The following takes the user inputted password (password)
//and "encrypts" it using MD5.

$enc_pw = md5($password);

//The above variable (enc_pw), is now the encrypted password.
//If someone is signing up, you then continue your script to enter
//it into a file, database, etc.

?>
```


```
<?php

//Now say somebody is going to be "logging" in or whatever.  First
//you would pull in the user info (username, password, etc) from
//your database, file, etc.  (Assume this has already been done)

//The variable (password) is the password the user enters in the
//form for logging in.  The variable (src_pw) is the password from
//the file, database, etc.  So know what you do is pretty simple.

$enc_pw = md5($password);

//The password the user entered needs to be "encrypted".  Now
//that that has been done, you can compare the user inputted
//password to the database/file/etc password.

if ($enc_pw=="$src_pw")
{
        //Then in here you put whatever needs to be done if the
        //passwords match (IE, successful login).
}
else
{
        //Then in here you put whatever needs to be done if the
        //passwords do not match (IE, incorrect login info).

        echo "[B]Error[/B]

";
        echo "The username/password that you entered is not valid";
}

?>
```
The above is very simple and straight to the point on how you can use MD5 ("encryption") with use for a password.

Hope it helps you. 

*EDIT: Although I am sure you may have already looked it over, this might also be of help:

http://www.php.net/manual/en/function.md5.php*


----------



## CyBerAliEn (Nov 25, 2001)

Maybe the following might help a little. Its similar to the above but you can see it "working" and look at the code:

http://www.planetubh.com/core/permtemp/md5_testing.php


----------



## Snake~eyes (Apr 18, 2002)

That's right,

basically it encrypts a password into somthing that cannot be read.

So when you do your check to the password in the database it encrypts what the user typed in and see if it matches the already encrypted thing in the database.

Simple as that


----------



## cassamine (Nov 22, 2002)

Well thaks all you guys.
Now i know what kind of encryption it is.

I also want to impement the MD5 function in another project
An application level intepreter.

I have made an equivalent encryption method but i need to implement exact "md5()" encrtyption function.

Anybody knows how exactly it encrypts?

cassamine


----------



## brendandonhu (Jul 8, 2002)

MD5 isn't really encryption, its hashing.
It can not be decrypted in any way.
What programming language are you using? There is MD5 available for all languages from C++ to Javascript.
You can read a bit about MD5 in the thread called "Javascript Junk" in Site Comments & Suggestions. I have been playing with Javascript MD5. Heres a little example of that, it takes a list of words, hashes them, and displays the word and its MD5 hash.
http://mywebpages.comcast.net/brendandonhue/md5.html


----------



## Snake~eyes (Apr 18, 2002)

> _Originally posted by brendandonhu:_
> *MD5 isn't really encryption, its hashing.
> *


*
not even really.. it isn't encryption.




Originally posted by brendandonhu:
What programming language are you using? 

Click to expand...

I just assumed it was PHP. Oh well.. lol*


----------



## cassamine (Nov 22, 2002)

Im developing in VB6 & c++ combined. I need to implement MD5 in both. Source in anyone will be enough.
I want to understand the logic of it's working.

What is Hashing?

cassamine


----------



## cassamine (Nov 22, 2002)

hey brendandonhu
i downloaded ur md5.js, thanks it's enough for me to understand it.

What is the concept of Hashing?

cassamine


----------



## brendandonhu (Jul 8, 2002)

The concept? YOu can take a string (or a binary file for that matter) and create a unique identifier for it. Using MD5 hashing, you can store the hash of a password on your server, the user enters it, its hashes, and compare the hashes. That how TSGs login works.


----------



## brendandonhu (Jul 8, 2002)

C++ MD5 is here
http://userpages.umbc.edu/~mabzug1/cs/md5/md5-cc-102.tar.gz


----------



## cassamine (Nov 22, 2002)

ok i under stand what is a hash.
Some questions came up my mind, but then i figured them out. hehe
thanks a lot.

cassamine


----------

