English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I know how to put normal variables in a database and retreive them but how would i do this for md5'd variables.
What steps would i need to do to first encrypt a variable with m5d. Insert it into a database, and then retriving it.

Detail please, 10 points for a good answer

2007-02-19 08:24:37 · 1 answers · asked by peter s 1 in Computers & Internet Programming & Design

1 answers

You can store MD5 variables as normal text or as a byte array.

You retrieve the variable the same way as you would any other value. You now have an MD5 hash value retrieved from the database. If this is for a password, you will then want to hash the password the user supplied and compare the two. For example:

storedHash = retrieve MD5 from database
tryPassword = password someone is trying to enter

if ( md5(tryPassword) == storedHash ) then the passwords match, because the hash of the password they tried matches the hash of the password you stored. Otherwise, they don't match.

In PHP, MD5 hashing of a string is simply done by calling md5() on the string you want to hash.

2007-02-19 08:29:15 · answer #1 · answered by Rex M 6 · 0 0

fedest.com, questions and answers