1.20.x password.inc | _password_base64_encode($input, $count) |
Encodes bytes into printable base 64 using the *nix standard from crypt().
Parameters
$input: The string containing bytes to encode.
$count: The number of characters (bytes) to encode.
Return value
Encoded string:
File
- includes/
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;
}