API15

JLDAP/generatePassword

From Joomla! Documentation

< API15:JLDAP
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...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

[Edit Descripton]

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 />