function ldap_servers_random_salt in Lightweight Directory Access Protocol (LDAP) 7
Same name and namespace in other branches
- 8.2 ldap_servers/ldap_servers.encryption.inc \ldap_servers_random_salt()
- 7.2 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.
2 calls to ldap_servers_random_salt()
- ldap_servers_install in ldap_servers/
ldap_servers.install - Implements hook_install().
- _ldap_servers_encrypt in ldap_servers/
ldap_servers.encryption.inc - Encrypt Password Method
File
- ldap_servers/
ldap_servers.encryption.inc, line 21 - Provides functions for encryption/decryption. http://stackoverflow.com/questions/2448256/php-mcrypt-encrypting-decrypt...
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;
}