Back to Totp class

Method hashToInt

protected string
hashToInt
(mixed $bytes, mixed $start)
Extracts a part of a hash as an integer
Parameters
  • string $bytes The hash
  • string $start The char to start from (0 = first char)
Returns
  • string
Class: Totp
Project: Joomla

Method hashToInt - Source code

/**
 * Extracts a part of a hash as an integer
 *
 * @param   string  $bytes  The hash
 * @param   string  $start  The char to start from (0 = first char)
 *
 * @return  string
 */
protected function hashToInt($bytes, $start)
{
    $input = substr($bytes, $start, \strlen($bytes) - $start);
    $val2 = unpack("N", substr($input, 0, 4));
    return $val2[1];
}