How can we encrypt the username and password using PHP?
Answers were Sorted based on User's Feedback
Answer / master
best is to use md5() or sha1(). base64_encode is not
actually encoding used for username or password.
Is This Answer Correct ? | 27 Yes | 0 No |
Answer / abhijita
This is an example Login with encrypted password but don't
forget to encrypt password and insert into database in sign
up process.
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// encrypt password
$encrypted_mypassword=md5($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername'
and password='$encrypted_mypassword'";
$result=mysql_query($sql);
Is This Answer Correct ? | 13 Yes | 3 No |
Answer / susanta karmakar
By using base64_encode() we can encrypt the username and
password.
Is This Answer Correct ? | 14 Yes | 5 No |
Answer / vikash
md5() is the best method for encrypting the username and
password.
Is This Answer Correct ? | 7 Yes | 0 No |
Answer / indrajit saha
This is an example Login with encrypted password:-
---------------------------------------------------
<?php
echo "Encrypting <b>testing</b> using md5: ".md5("testing");
echo "<br />";
echo "Encrypting <b>testing</b> using sha1: ".sha1("testing");
?>
Output:-
---------
Encrypting testing using md5: ae2b1fca515949e5d54fb22b8ed95575
Encrypting testing using sha1:
dc724af18fbdd4e59189f5fe768a5f8311527050
Is This Answer Correct ? | 8 Yes | 1 No |
Answer / zahid
$username = $conn->escape_string($_POST['usernmae]);
$password = $conn->escape_string($_POST['password]);
$sql ="SELECT usernmae,password,id from login where md5(usernmae)='$username' and md5(password)='$password';";
$row = $conn->query($sql);
if($row->num_rows >0){
echo "login success";
}
else{
echo "Invalid credentaisl";
}
Is This Answer Correct ? | 0 Yes | 0 No |
What is the default session out time?
how to upload more than 50 mb? i tried but session was expired....certain time .....i was set session duration three days .... how to rectified? if any one know that post ur answer as soon as possible? thanks
Explain Creating and Naming an Array?
Explain converting an object?
What is the functionality of the function html entities?
am from coimbatore.am learning php&mysql. what will be the approx salary for me if i get a job in coimbatore.
How to create a table to store files?
List some of the features of php7.
What is asort php?
What is the difference between $var and $$var?
How do you find the length of a string in php?
How easy is php?