Code

Updated gosaLastSystemLogin to gotoLastSystemLogin
[gosa.git] / include / class_password-methods-smd5.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2004  Fabian Hickert 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
22 class passwordMethodsmd5 extends passwordMethod
23 {
24   function passwordMethodsmd5($config)  
25   {
26   }
28   function is_available()
29   {
30     if ((!function_exists('md5'))){
31       return false;     
32     }else{
33       return true;
34     }
35   }
37   function generate_hash($pwd)
38   {
39     mt_srand(microtime()* 10000000);
40     $salt0= substr(pack("h*", md5(mt_rand())), 0, 8);
41     $salt = substr(pack("H*", md5($salt0 . $pwd)), 0, 4);
42     $hash = "{SMD5}".base64_encode(pack("H*",md5($pwd . $salt)) . $salt);
43     return $hash;       
44   }
45 }
47 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
48 ?>