function _password_base64_encode in Simple LDAP 7
Same name and namespace in other branches
- 7.2 simple_ldap_user/simple_ldap_user.password.inc \_password_base64_encode()
Encode bytes into printable base 64 using the *nix standard from crypt().
Parameters
string $input: The string containing bytes to encode.
integer $count: The number of characters (bytes) to encode.
Return value
string Encoded string
2 calls to _password_base64_encode()
- _password_crypt in simple_ldap_user/
simple_ldap_user.password.inc - Hash a password using a secure stretched hash.
- _password_generate_salt in simple_ldap_user/
simple_ldap_user.password.inc - Generates a random base 64-encoded salt prefixed with settings for the hash.
File
- simple_ldap_user/
simple_ldap_user.password.inc, line 56 - Secure password hashing functions for user authentication.
Code
function _password_base64_encode($input, $count) {
$output = '';
$i = 0;
$itoa64 = _password_itoa64();
do {
$value = ord($input[$i++]);
$output .= $itoa64[$value & 0x3f];
if ($i < $count) {
$value |= ord($input[$i]) << 8;
}
$output .= $itoa64[$value >> 6 & 0x3f];
if ($i++ >= $count) {
break;
}
if ($i < $count) {
$value |= ord($input[$i]) << 16;
}
$output .= $itoa64[$value >> 12 & 0x3f];
if ($i++ >= $count) {
break;
}
$output .= $itoa64[$value >> 18 & 0x3f];
} while ($i < $count);
return $output;
}