You are here

function random_salt in LDAP integration 6

Return a random salt of a given length for crypt-style passwords

*Most of the code here is from phpLDAPadmin.

1 call to random_salt()
encode_password in ./ldapdata.module
Return an encrypted password

File

./ldapdata.module, line 896
ldapdata provides data maping against ldap server.

Code

function random_salt($length) {
  $possible = '0123456789' . 'abcdefghijklmnopqrstuvwxyz' . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . './';
  $str = "";
  mt_srand((double) microtime() * 1000000);
  while (strlen($str) < $length) {
    $str .= substr($possible, rand() % strlen($possible), 1);
  }
  return $str;
}