protected function PhpassHashedPassword::base64Encode

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 PhpassHashedPassword::base64Encode()
PhpassHashedPassword::crypt in drupal/core/lib/Drupal/Core/Password/PhpassHashedPassword.php
Hash a password using a secure stretched hash.
PhpassHashedPassword::generateSalt in drupal/core/lib/Drupal/Core/Password/PhpassHashedPassword.php
Generates a random base 64-encoded salt prefixed with settings for the hash.

File

drupal/core/lib/Drupal/Core/Password/PhpassHashedPassword.php, line 69
Definition of Drupal\Core\Password\PhpassHashedPassword

Class

PhpassHashedPassword
Secure password hashing functions based on the Portable PHP password hashing framework.

Namespace

Drupal\Core\Password

Code

protected function base64Encode($input, $count) {
  $output = '';
  $i = 0;
  do {
    $value = ord($input[$i++]);
    $output .= static::$ITOA64[$value & 0x3f];
    if ($i < $count) {
      $value |= ord($input[$i]) << 8;
    }
    $output .= static::$ITOA64[$value >> 6 & 0x3f];
    if ($i++ >= $count) {
      break;
    }
    if ($i < $count) {
      $value |= ord($input[$i]) << 16;
    }
    $output .= static::$ITOA64[$value >> 12 & 0x3f];
    if ($i++ >= $count) {
      break;
    }
    $output .= static::$ITOA64[$value >> 18 & 0x3f];
  } while ($i < $count);
  return $output;
}