summaryrefslogtreecommitdiff
path: root/inc/PassHash.class.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2011-01-23 10:55:23 +0100
committerAndreas Gohr <andi@splitbrain.org>2011-01-23 10:55:23 +0100
commit52c9860c6e3a36b884ca186f1c9ea3d7acdf2b13 (patch)
tree60b74312126ad6ad38edc76256348cbcdf7fdc82 /inc/PassHash.class.php
parent3e1ca056e645515478add4931738a5f476e1bf3e (diff)
downloadrpg-52c9860c6e3a36b884ca186f1c9ea3d7acdf2b13.tar.gz
rpg-52c9860c6e3a36b884ca186f1c9ea3d7acdf2b13.tar.bz2
django pass hashes have no leading $
Diffstat (limited to 'inc/PassHash.class.php')
-rw-r--r--inc/PassHash.class.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/inc/PassHash.class.php b/inc/PassHash.class.php
index dce1a5ace..c4a6d78d0 100644
--- a/inc/PassHash.class.php
+++ b/inc/PassHash.class.php
@@ -41,10 +41,10 @@ class PassHash {
$method = 'pmd5';
$salt = $m[1];
$magic = 'H';
- }elseif(preg_match('/^\$sha1\$(.{5})\$/',$hash,$m)){
+ }elseif(preg_match('/^sha1\$(.{5})\$/',$hash,$m)){
$method = 'djangosha1';
$salt = $m[1];
- }elseif(preg_match('/^\$md5\$(.{5})\$/',$hash,$m)){
+ }elseif(preg_match('/^md5\$(.{5})\$/',$hash,$m)){
$method = 'djangomd5';
$salt = $m[1];
}elseif(substr($hash,0,6) == '{SSHA}'){
@@ -348,13 +348,14 @@ class PassHash {
* Uses salted SHA1 hashs. Salt is 5 bytes long.
* This is used by the Django Python framework
*
+ * @link http://docs.djangoproject.com/en/dev/topics/auth/#passwords
* @param string $clear - the clear text to hash
* @param string $salt - the salt to use, null for random
* @returns string - hashed password
*/
public function hash_djangosha1($clear, $salt=null){
$this->init_salt($salt,5);
- return '$sha1$'.$salt.'$'.sha1($salt.$clear);
+ return 'sha1$'.$salt.'$'.sha1($salt.$clear);
}
/**
@@ -363,13 +364,14 @@ class PassHash {
* Uses salted MD5 hashs. Salt is 5 bytes long.
* This is used by the Django Python framework
*
+ * @link http://docs.djangoproject.com/en/dev/topics/auth/#passwords
* @param string $clear - the clear text to hash
* @param string $salt - the salt to use, null for random
* @returns string - hashed password
*/
public function hash_djangomd5($clear, $salt=null){
$this->init_salt($salt,5);
- return '$md5$'.$salt.'$'.md5($salt.$clear);
+ return 'md5$'.$salt.'$'.md5($salt.$clear);
}
}