[dev] Patch for framework: Auth/sql.php

Amith Varghese amith at xalan.com
Fri Jan 30 07:54:31 PST 2004


Quoting Chuck Hagenbuch <chuck at horde.org>:

>
> I'd agree - any chance you can send a patch? :)

Here you go.  It's simple enough but since I'm using LDAP for authentication I
couldn't test it.

Amith
-------------- next part --------------
Index: framework/Auth/Auth/sql.php
===================================================================
RCS file: /repository/framework/Auth/Auth/sql.php,v
retrieving revision 1.57
diff -u -r1.57 sql.php
--- framework/Auth/Auth/sql.php	28 Jan 2004 00:34:00 -0000	1.57
+++ framework/Auth/Auth/sql.php	30 Jan 2004 15:59:17 -0000
@@ -308,46 +308,46 @@
 
         case 'sha':
             $newPassword = base64_encode(mhash(MHASH_SHA1, $newPassword));
-            $newPassword .= $this->_params['show_encryption'] ? '{SHA}' : '';
+            $newPassword = $this->_params['show_encryption'] ? '{SHA}' . $newPassword : $newPassword;
             break;
 
         case 'crypt':
         case 'crypt-des':
             $salt = substr(md5(mt_rand()), 0, 2);
             $newPassword = crypt($newPassword, $salt);
-            $newPassword .= $this->_params['show_encryption'] ? '{crypt}' : '';
+            $newPassword = $this->_params['show_encryption'] ? '{crypt}' . $newPassword : $newPassword;
             break;
 
         case 'crypt-md5':
             $salt = '$1$' . substr(md5(mt_rand()), 0, 8) . '$';
             $newPassword = crypt($newPassword, $salt);
-            $newPassword .= $this->_params['show_encryption'] ? '{crypt}' : '';
+            $newPassword = $this->_params['show_encryption'] ? '{crypt}' . $newPassword : $newPassword;
 
         case 'crypt-blowfish':
             $salt = '$2$' . substr(md5(mt_rand()), 0, 12) . '$';
             $newPassword = crypt($newPassword, $salt);
-            $newPassword .= $this->_params['show_encryption'] ? '{crypt}' : '';
+            $newPassword = $this->_params['show_encryption'] ? '{crypt}' . $newPassword : $newPassword;
 
         case 'md5-base64':
             $newPassword = base64_encode(mhash(MHASH_MD5, $newPassword));
-            $newPassword .= $this->_params['show_encryption'] ? '{MD5}' : '';
+            $newPassword = $this->_params['show_encryption'] ? '{MD5}' . $newPassword : $newPassword;
             break;
 
         case 'ssha':
             $salt = mhash_keygen_s2k(MHASH_SHA1, $newPassword, substr(pack("h*", md5(mt_rand())), 0, 8), 4);
             $newPassword = base64_encode(mhash(MHASH_SHA1, $newPassword . $salt) . $salt);
-            $newPassword .= $this->_params['show_encryption'] ? '{SSHA}' : '';
+            $newPassword = $this->_params['show_encryption'] ? '{SSHA}' . $newPassword : $newPassword;
             break;
 
         case 'smd5':
             $salt = mhash_keygen_s2k(MHASH_MD5, $newPassword, substr(pack("h*", md5(mt_rand())), 0, 8), 4);
             $newPassword = base64_encode(mhash(MHASH_SMD5, $newPassword . $salt) . $salt);
-            $newPassword .= $this->_params['show_encryption'] ? '{SMD5}' : '';
+            $newPassword = $this->_params['show_encryption'] ? '{SMD5}' . $newPassword : $newPassword;
             break;
 
         case 'md5-hex':
         default:
-            $newPassword = md5($newPassword);
+            $newPassword = $this->_params['show_encryption'] ? '{MD5}' . md5($newPassword) : md5($newPassword);
             break;
         }
         return $newPassword;


More information about the dev mailing list