OTPHP\OTP::generateOTP PHP Метод

generateOTP() защищенный Метод

protected generateOTP ( integer $input ) : string
$input integer
Результат string The OTP at the specified input
    protected function generateOTP($input)
    {
        $hash = hash_hmac($this->getDigest(), $this->intToByteString($input), $this->getDecodedSecret());
        $hmac = [];
        foreach (str_split($hash, 2) as $hex) {
            $hmac[] = hexdec($hex);
        }
        $offset = $hmac[count($hmac) - 1] & 0xf;
        $code = ($hmac[$offset + 0] & 0x7f) << 24 | ($hmac[$offset + 1] & 0xff) << 16 | ($hmac[$offset + 2] & 0xff) << 8 | $hmac[$offset + 3] & 0xff;
        $otp = $code % pow(10, $this->getDigits());
        return str_pad((string) $otp, $this->getDigits(), '0', STR_PAD_LEFT);
    }