password decode help
Moderator: General Moderators
password decode help
$sql = "select password from login where email = '".$email."' ";
$result = mysql_query($sql);
if($row = mysql_fetch_array($result))
{
//note $pass = "decode( '".$row["password"]."' , $pass)";
}
how can i decode the password ? i dont knw where goes wrong but the password i receive still encode
$result = mysql_query($sql);
if($row = mysql_fetch_array($result))
{
//note $pass = "decode( '".$row["password"]."' , $pass)";
}
how can i decode the password ? i dont knw where goes wrong but the password i receive still encode
-
Yonderknight
- Forum Commoner
- Posts: 31
- Joined: Sun Jun 13, 2004 6:51 pm
ok, so you've used md5() to hash the password, which is ok, just means you can't 'de-hash' it as it's one way.
What you need to do is compare the md5() of the password the user supplies against the password in the db.
E.g.
if($row['password'] == md5($_POST['thepassword'])){
//ok
} else {
//not ok
}
That presumes the password the user supplies is coming from a form post, but you get the idea ? :0
What you need to do is compare the md5() of the password the user supplies against the password in the db.
E.g.
if($row['password'] == md5($_POST['thepassword'])){
//ok
} else {
//not ok
}
That presumes the password the user supplies is coming from a form post, but you get the idea ? :0
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
This can be found @ php.net/rand
Code: Select all
<?php
Yet another random password generator, but this one creates readable/pronounceable passwords...
<?php
function randompass()
{
$rand_pass = ''; // makes sure the $pass var is empty.
for( $j = 0; $j < 3; $j++ )
{
$startnend = array(
'b','c','d','f','g','h','j','k','l','m','n',
'p','q','r','s','t','v','w','x','y','z',
);
$mid = array(
'a','e','i','o','u','y',
);
$count1 = count( $startnend ) - 1;
$count2 = count( $mid ) - 1;
for( $i = 0; $i < 3; $i++)
{
if( $i != 1 )
{
$rand_pass .= $startnend[rand( 0, $count1 )];
}
else
{
$rand_pass .= $mid[rand( 0, $count2 )];
}
}
}
return $rand_pass;
}
$rand_pass = randompass();
echo '<p>pass: <strong>' . $rand_pass . '</strong></p>';
echo '<p>md5: <strong>' . md5( $rand_pass ) . '</strong></p>';
?>
Some examples are:-
pohyerdib
kibkudjam
fizvoszeb
jyshevram
Easy to remember (since it's basically 3, 3 letter words)
I've put a y in the list of vowels since it works well as a middle letter in the 3 letter words.
This is excellent for a random password generator for a 'forgot password' type function.
?>