[Drupy-general] password.inc
Status: Inactive
Brought to you by:
message144
|
From: Fernando P. G. <fer...@gm...> - 2008-10-03 05:35:19
|
password.inc is 99% ready but I have a problem with "pass" statement:
PHP version:
function user_check_password($password, $account) {
if (substr($account->pass, 0, 3) == 'U$P') {
// This may be an updated password from user_update_7000(). Such hashes
// have 'U' added as the first character and need an extra md5().
$stored_hash = substr($account->pass, 1);
$password = md5($password);
}
else {
$stored_hash = $account->pass;
}
$hash = _password_crypt($password, $stored_hash);
return ($hash && $stored_hash == $hash);
}
Python version:
def user_check_password(password, account):
if (substr(account.pasw, 0, 3) == 'U$P'):
# This may be an updated password from user_update_7000(). Such hashes
# have 'U' added as the first character and need an extra md5().
stored_hash = substr(account.pasw, 1)
password = php.md5(password)
else:
stored_hash = account.pasw
hash = _crypt(password, stored_hash)
return (hash and stored_hash == hash)
I have renamed "pass" to "pasw", because Drupal plays with arrays to
objects and sometimes objects to arrrays, I don't really know how
$account got the property "pass" or can I just account['pass']?
Blessings and Thanks in advance!
|