Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,959 questions

51,901 answers

573 users

How to secure a password using password hashing in PHP

3 Answers

0 votes
// Researchers have found flaws in the SHA1 and MD5 algorithms. So don't use them, 
// use sha256, sha512 or BCrypt

$rv = mysql_query("INSERT INTO users (user, password)
          VALUES(
            '".$_POST['username']."',
            '".md5($_POST['password'])."'
        )", $con);


$row = mysql_fetch_assoc(mysql_query("SELECT user FROM users WHERE user='{$_POST['username']}' 
                                      AND password='".md5($_POST['password'])."'", $con));


/*
run:
    

      
*/


answered Apr 26, 2014 by avibootz
edited Jul 19, 2016 by avibootz
0 votes
// You can't retrieve a password from a one-way hash
// If the user forgot his password, you need to send him a link for create new password

$password = "12345";
$password = hash("sha256", $password);
echo $password;


/*
run:
    
5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5 
      
*/

 



answered Jul 19, 2016 by avibootz
edited Jul 19, 2016 by avibootz
0 votes
// You can't "retrieve" a password from a one-way hash like SHA512 
// If use forgot the password, you neet to send him a link for create new password

$password = "12345";
$password = hash("sha512", $password);
echo $password;


/*
run:
    
3627909a29c31381a071ec27f7c9ca97726182aed29a7ddd2e54353322cfb30abb9e3a6df2ac2c20fe23436311d678564d0c8d305930575f60e2d3d048184d79 
      
*/

 



answered Jul 19, 2016 by avibootz
...