[Ltb-changes] r45 - self-service-password/trunk

coudot at ltb-project.org coudot at ltb-project.org
Wed Nov 25 09:39:58 CET 2009


Author: coudot
Date: 2009-11-25 09:39:58 +0100 (Wed, 25 Nov 2009)
New Revision: 45

Modified:
   self-service-password/trunk/config.inc.php
   self-service-password/trunk/functions.inc.php
   self-service-password/trunk/index.php
Log:
#147: SHA, SMD5 and MD5 encryptions

Modified: self-service-password/trunk/config.inc.php
===================================================================
--- self-service-password/trunk/config.inc.php	2009-10-31 21:52:15 UTC (rev 44)
+++ self-service-password/trunk/config.inc.php	2009-11-25 08:39:58 UTC (rev 45)
@@ -36,6 +36,9 @@
 
 # Hash mechanism for password:
 # SSHA
+# SHA
+# SMD5
+# MD5
 # clear (the default)
 # This option is not used with ad_mode = on
 $hash = "clear";

Modified: self-service-password/trunk/functions.inc.php
===================================================================
--- self-service-password/trunk/functions.inc.php	2009-10-31 21:52:15 UTC (rev 44)
+++ self-service-password/trunk/functions.inc.php	2009-11-25 08:39:58 UTC (rev 45)
@@ -20,13 +20,33 @@
 #==============================================================================
 
 # Create SSHA password
-function make_ssha_password($password){
+function make_ssha_password($password) {
     mt_srand((double)microtime()*1000000);
     $salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand());
     $hash = "{SSHA}" . base64_encode(pack("H*", sha1($password . $salt)) . $salt);
     return $hash;
 }
 
+# Create SHA password
+function make_sha_password($password) {
+    $hash = "{SHA}" . base64_encode(pack("H*", sha1($password)));
+    return $hash;
+}
+
+# Create SMD5 password
+function make_smd5_password($password) {
+    mt_srand((double)microtime()*1000000);
+    $salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand());
+    $hash = "{SMD5}" . base64_encode(pack("H*", md5($password . $salt)) . $salt);
+    return $hash;
+}
+
+# Create MD5 password
+function make_md5_password($password) {
+    $hash = "{MD5}" . base64_encode(pack("H*", md5($password)));
+    return $hash;
+}
+
 # Strip slashes added by PHP
 # Only if magic_quote_gpc is not set to off in php.ini
 function stripslashes_if_gpc_magic_quotes( $string ) {

Modified: self-service-password/trunk/index.php
===================================================================
--- self-service-password/trunk/index.php	2009-10-31 21:52:15 UTC (rev 44)
+++ self-service-password/trunk/index.php	2009-11-25 08:39:58 UTC (rev 45)
@@ -126,6 +126,15 @@
         if ( $hash == "SSHA" ) {
             $newpassword = make_ssha_password($newpassword);
         }
+        if ( $hash == "SHA" ) {
+            $newpassword = make_sha_password($newpassword);
+        }
+        if ( $hash == "SMD5" ) {
+            $newpassword = make_smd5_password($newpassword);
+        }
+        if ( $hash == "MD5" ) {
+            $newpassword = make_md5_password($newpassword);
+        }
     }
 
     # Rebind as Manager if needed



More information about the ltb-changes mailing list