Jump to content

When showing user admin page - Password Question


shaggycap

Recommended Posts

I'm building a user admin section on my CMS, and have a page showing the details of a user that you can edit.

I can't just display the password field as its an MD5 hash, so what would be the best approach here? Obviously I can't decode it so I wondered how you dealt with something like this?
Yeah. I mean we can view our members passwords here at PHPFreaks, but we don't because it is never needed.......


April Fools!  Hmm.....not april! Damn!  Oh well.  The point is, don't do it. Because some people use one password for EVERYTHING
[quote author=steelmanronald06 link=topic=117581.msg480844#msg480844 date=1165538527]
Or just not MD5 your password, which is highly ill advised.
[/quote]
I suspect this might be some sort of twisted sarcasm, but if it isn't, would you care to explain why it's a good idea to store passwords in plain text?
[quote author=Albright link=topic=117581.msg485135#msg485135 date=1166141029]
[quote author=steelmanronald06 link=topic=117581.msg480844#msg480844 date=1165538527]
Or just not MD5 your password, which is highly ill advised.
[/quote]
I suspect this might be some sort of twisted sarcasm, but if it isn't, would you care to explain why it's a good idea to store passwords in plain text?
[/quote]He said that it was ill advised, meaning he's saying its a bad thing to do.
[quote author=Daniel0 link=topic=117581.msg485297#msg485297 date=1166166677]
Take a look at [url=http://php.net/mcrypt]mcrypt[/url]
[/quote]

Mcrypt has decryptable algorithms, not hashes. For passwords use hashes.

http://nl2.php.net/manual/en/ref.hash.php
semi- on-topic, if one decided to drop MD5 from their sites and port to a new type of encryption, am i right in thinking that you'd need to prompt the user for a new password that would be encrypted in the new method? or am I missing an easy way?
not necessarily..
[code]<?php

if (sha1($password . $salt) !== $passwordFromDB)
{
    if (md5($password . $salt) !== $passwordFromDB)
    {
        die('password incorrect');
    }
    else
    {
        $passwordFromDB = sha1($password . $salt);
    }
}

echo 'Welcome';

?>[/code]

edit: removed false-false.
I think you want to remove those ! from before sha1 or md5, but yeah, that should work; just transparently re-hash the password if the old hash algorithm shows that it is correct.

One thing to keep in mind is that md5() creates a string of 32 characters, and sha1() creates 40 characters. If you've set up the password field in your database to only hold 32 characters, you should modify it first to fit all 40 characters that a sha1() call will give you.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.