function ldap_servers_random_salt in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_servers/ldap_servers.encryption.inc \ldap_servers_random_salt()
- 7 ldap_servers/ldap_servers.encryption.inc \ldap_servers_random_salt()
Return a random salt of a given length for crypt-style passwords.
Parameters
int length: The requested length.
Return value
string A (fairly) random salt of the requested length.
File
- ldap_servers/
ldap_servers.encryption.inc, line 17 - Provides functions for encryption/decryption.
Code
function ldap_servers_random_salt($length) {
$possible = '0123456789' . 'abcdefghijklmnopqrstuvwxyz' . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . './';
$salt = "";
mt_srand((double) microtime() * 1000000);
while (strlen($salt) < $length) {
$salt .= substr($possible, rand() % strlen($possible), 1);
}
return $salt;
}