Page 1 of 1

SELECT AES_DECRYPT()

Posted: Tue Sep 04, 2012 3:46 pm
by ssusa
Hey everyone,

this is my first problem that I have come across which I am really stuck on and can not find any solutions. I am currently trying to create a secure way of storing user passwords in the database using AES_ENCRYPT. I have succesfully inserted the encrypted password into the mysql database, however I can not retrieve the decrypted value from the database using the following code...

Code: Select all

	$SQLstring="SELECT AES_DECRYPT(password,'$key') FROM accounts WHERE username='$ac_username'";
	$QueryResult = $DBConnect -> query($SQLstring);
	$row = mysqli_fetch_array($QueryResult);
	echo $row[0];
	if ($row[0] == $ac_password){
		session_register($ac_username);
		session_register($ac_password); 
		header("location:account.php");
	}
	else {
		
	}
When I enter in the SQLstring in the phpmyadmin sql console it will try to return a value from the field "AES_DECRYPT(password,'$key')" for some reason, which returns NULL. I assume that means it is trying to find an actual field associated with the row that is selected.

Please someone help!

Re: SELECT AES_DECRYPT()

Posted: Tue Sep 04, 2012 6:01 pm
by social_experiment