MyBB Community Forums

Full Version: the method of encryption password in mybb database
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
guys can someone tel me the mybb use what method to encrypt password in database?
because i have problem with this code every time i use user and password (correct user and pass) i have error : "incorrect user and password"

i put for you 3part of my code that i need help on this(i think i have a problem on class Login ):

thank you for help.



	class DB
	{
		var $connection;
		var $started;
		
		function start()
		{
			global $MySQL_Host, $MySQL_User, $MySQL_Pass, $MySQL_DB;
			
			$this->connection = mysql_connect( $MySQL_Host, $MySQL_User,     $MySQL_Pass );
			mysql_select_db( $MySQL_DB, $this->connection );
		}
		
		function query( $query )
		{
			$result = mysql_query( $query, $this->connection );
			
			if( $result )
			{
				return mysql_fetch_full_result_array( $result );
			}
			else
			{
				return $result;
			}
		}
		
		function end()
		{
			mysql_close( $this->connection );
		}
		
		function isStarted()
		{
			return $started;
		}
	}

    function mysql_fetch_full_result_array( $result )
	{
		$table_result = array();
		$r = 0;
		
		if( $result === true )
		{
			return $result;
		}
		
		if( mysql_num_rows( $result ) == 0 )
		{
			return $result;
		}
		
		while( $row = mysql_fetch_assoc( $result ) )
		{
			$arr_row = array();
			$c = 0;
			
			while ( $c < mysql_num_fields( $result ) )
			{       
				$col = mysql_fetch_field( $result, $c );   
				$arr_row[ $col -> name ] = $row[ $col -> name ];           
				$c++;
			}   
			
			$table_result[ $r ] = $arr_row;
			$r++;
		}   
		
		return $table_result;
	}

	
	class Login
	{
		
		function CheckLogin( $username, $password )
		{
			$db = new DB();
			$db->start();
			
			$query = "SELECT uid, password, email FROM mybb_users WHERE username='".$username."' AND password='".md5(md5($salt).md5($password))."';";
			
			$result = $db->query( $query );
			
			$db->end();
			
			if( $result == false )
				return false;
     //				fwrite($fh, $result);
     //				fclose($fh);
				
				
			if( md5(md5($salt).md5($password)) == $result[ 0 ][ 'password' ] )
			{
				return array( 'uid' => $result[ 0 ][ 'uid' ],
							  'mail' => $result[ 0 ][ 'email' ],
							  'user' => $username
							);
			}
		}
	}

i need help pleas help :|
ye its nice wiki about md5....
but my question is another thing :|
i need edit this code how to check mybb password.
also i waiting some one help me
if you check my post can see i use that method:

 if( md5(md5($salt).md5($password)) == $result[ 0 ][ 'password' ] )
but not work at all i thing i have a problem on code!!!
If you check that post carefully you don't use that method completely. Compare your code to the one in post I mentioned. You haven't defined few things.
Huh

I can't solve that so pleas do it for me.
$salt is not defined, thus a md5 of an undefined variable returns false.
So what is the true code? pleas post here pleas pleas