function random_salt in Lightweight Directory Access Protocol (LDAP) 6
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.
1 call to random_salt()
- encrypt_password in includes/
ldap.encryption.inc - Encrypt Password Method
File
- includes/
ldap.encryption.inc, line 20 - Provides functions for encryption/decryption.
Code
function 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;
}