diff options
Diffstat (limited to 'php/admin/include')
-rw-r--r-- | php/admin/include/passwd.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/php/admin/include/passwd.php b/php/admin/include/passwd.php new file mode 100644 index 0000000..7fa02af --- /dev/null +++ b/php/admin/include/passwd.php @@ -0,0 +1,26 @@ +<?php +/* ------------------------------------------------------------------- + Copyright (C) 2007 by Intevation GmbH + Author(s): + Sascha Wilde <wilde@intevation.de> + + This program is free software under the GNU GPL (>=v2) + Read the file COPYING coming with the software for details. + ------------------------------------------------------------------- */ + +// Generate OpenLDAP style SSHA password strings +function ssha($string, $salt) +{ + return "{SSHA}" . base64_encode(pack("H*", sha1($string . $salt)) . $salt); +} + +// return 4 random bytes +function gensalt() +{ + $salt = ''; + while (strlen($salt) < 4) + $salt = $salt . chr(mt_rand(0,255)); + return $salt; +} + +?>
\ No newline at end of file |