JLDAP/generatePassword
From Joomla! Documentation
< API15:JLDAPRevision as of 17:14, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description===
Generates a LDAP compatible password
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowik...)
Revision as of 17:14, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description===
Generates a LDAP compatible password
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowik...)
The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Generates a LDAP compatible password
Template:Description:JLDAP/generatePassword
Syntax[edit]
generatePassword($password, $type='md5')
Parameter Name | Default Value | Description |
---|---|---|
$password | password Clear text password to encrypt | |
$type | 'md5' | type Type of password hash, either md5 or SHA |
Returns[edit]
string encrypted password
Defined in[edit]
libraries/joomla/client/ldap.php
Importing[edit]
jimport( 'joomla.client.ldap' );
Source Body[edit]
function generatePassword($password, $type='md5') {
$userpassword = '';
switch(strtolower($type)) {
case 'sha':
$userpassword = '{SHA}' . base64_encode( pack( 'H*', sha1( $password ) ) );
case 'md5':
default:
$userpassword = '{MD5}' . base64_encode( pack( 'H*', md5( $password ) ) );
break;
}
return $userpassword;
}
[Edit See Also] Template:SeeAlso:JLDAP/generatePassword
Examples[edit]
<CodeExamplesForm />