blob: 7fa02af26750e8ff1da10a5c6d5f4767c8064a33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
}
?>
|