If this helps you, I think Joomla has an encryption algorithm which works like this:
You create an user $user
You assign it a password $password
Joomla! creates a pseudo random array of 32 chars from A to Z a to z and 0 to 9 and call this array $salt
Joomla! creates another variable called $hash concatenating your variable user with the salt and get the md5 from all of it, like this... $hash = md5($user.$salt)
Joomla! saves a password which is again a concatenation of your hash then 2 points and then the salt, in this format.... $hash.":".$salt
That's why when you check out your database your password looks like this:
3977807f631949e190966ae148a073ee:8z2Geal1qzizkhSTN6hP4fMrnnRxXbrj
I try to connect my Joomla site with my php site so i try to enter into the Joomla! db, but splitting the variables to make it work, I will post the code for anyone who wants it...
login.php
Note: the login.php file only does the comparison between the already existing password in joomla's db, and does not crypt it, I'll try to edit this comment with the additional file tomorrow because I have to go, also i will translate the Spanish parts, sorry I'm from Mexico xD
conectar();
$myusername=$_POST['username'];
$mypassword=$_POST['password'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($contrasena);
if (isset($_POST['username']))
{
$pass="SELECT * FROM users WHERE username='$myusername'";
$result=mysql_query($pass);
$count=mysql_num_rows($result);
$row=mysql_fetch_array($result);
$pass=$row["password"];
list($hash,$salt) = explode(":",$pass); //split the bd password
$cripto = md5($mypassword.$salt); //md5 into pass+salt
if (($hash==$cripto) && ($count==1))
{
echo "true";
session_start();
$_SESSION['idUsuario'] = $row['idUser'];
$_SESSION['username'] = $myusername;
$_SESSION['password'] = $pass;
$_SESSION['rolUser'] = $row['rol'];
//header("location:login_success.php");
}
else
{
echo "false";
}
}
else
{
echo "false";
}
desconectar();
?>
conexion.php
And also I show you my conectar() code, which only performs the connections to the db
<?php
function conectar(){
$db_host="localhost";
$db_usuario="root";
$db_password="";
$db_nombre="joomla";
$conexion = @mysql_connect($db_host, $db_usuario, $db_password) or die(mysql_error());
if (!$conexion) {
die('Error in connection: ' . mysql_error());
}
else{
//echo "<div class='success'> Conectado satisfactoriamente </div>";
$db = @mysql_select_db($db_nombre, $conexion) or die(mysql_error());
}
}
function desconectar()
{
@mysql_close($conexion);
}
?>
finally, the crypter, it will be something like this:
crypter.php
<?php
function pseudoRandom($values)
{
$values = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
$chainNumber=$values;
$originalPassword = "";
for($i=0;$i<$chainNumber;$i++)
{
$originalPassword .= substr($values,rand(0,strlen($values)),1);
}
return $originalPassword;
}
$originalPassword = ’caca’;
$salt=pseudoRandom(32);
$hash=md5($cadena.$salt);
$finalPassword=$hash.”:”.$salt;
?>