index 961abc56a65296dd2956d70ccedb1935c1750b08..736db99cf295c868f0089ad5ae7d1cded0446568 100644 (file)
/* Build a sub-directory style list of the tree level
specified in $dn */
+ global $config;
+ $dn = preg_replace("/".normalizePreg($config->current['BASE'])."$/i","",$dn);
+ if(empty($dn)) return("/");
+
foreach (split(',', $dn) as $rdn){
/* We're only interested in organizational units... */
/* Extract used hash */
if ($hash == ""){
- $test = passwordMethod::get_method($attrs['userPassword'][0]);
+ $test = passwordMethod::get_method($attrs['userPassword'][0],$dn);
} else {
- $test = new $available[$hash]($config);
+ $test = new $available[$hash]($config,$dn);
$test->set_hash($hash);
}
} else {
return (chr ($randno + 59)); // Lowercase
}
- }
+}
+
+
+function cred_encrypt($input, $password) {
+
+ $size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
+ $iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM);
+
+ return bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $password, $input, MCRYPT_MODE_ECB, $iv));
+
+}
+
+function cred_decrypt($input,$password) {
+ $size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
+ $iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM);
+
+ return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $password, pack("H*", $input), MCRYPT_MODE_ECB, $iv);
+}
+
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>