public function SimpleLdap::salt in Simple LDAP 8
Generates a random salt of the given length.
2 calls to SimpleLdap::salt()
- SimpleLdap::hash in src/
SimpleLdap.php - Hash a string for use in an LDAP password field.
- SimpleLdap::hash in src/
SimpleLdap.php - Hash a string for use in an LDAP password field.
File
- src/
SimpleLdap.php, line 101
Class
- SimpleLdap
- A wrapper for PHP's LDAP functions, with associated helper methods.
Namespace
Drupal\simple_ldapCode
public function salt($length) {
$possible = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./';
$str = '';
while (strlen($str) < $length) {
$str .= substr($possible, rand() % strlen($possible), 1);
}
return $str;
}