[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Encrypt/ -> Totp.php (summary)

Joomla! Content Management System

Copyright: (C) 2013 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
File Size: 204 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Totp:: (7 methods):
  __construct()
  getPeriod()
  checkCode()
  getCode()
  hashToInt()
  getUrl()
  generateSecret()


Class: Totp  - X-Ref

This class provides an RFC6238-compliant Time-based One Time Passwords,
compatible with Google Authenticator (with PassCodeLength = 6 and TimePeriod = 30).

__construct($timeStep = 30, $passCodeLength = 6, $secretLength = 10, $base32 = null)   X-Ref
Initialises an RFC6238-compatible TOTP generator. Please note that this
class does not implement the constraint in the last paragraph of ยง5.2
of RFC6238. It's up to you to ensure that the same user/device does not
retry validation within the same Time Step.

param: int     $timeStep        The Time Step (in seconds). Use 30 to be compatible with Google Authenticator.
param: int     $passCodeLength  The generated passcode length. Default: 6 digits.
param: int     $secretLength    The length of the secret key. Default: 10 bytes (80 bits).
param: Object  $base32          The base32 en/decrypter

getPeriod($time = null)   X-Ref
Get the time period based on the $time timestamp and the Time Step
defined. If $time is skipped or set to null the current timestamp will
be used.

param: int|null  $time  Timestamp
return: integer  The time period since the UNIX Epoch

checkCode($secret, $code)   X-Ref
Check is the given passcode $code is a valid TOTP generated using secret
key $secret

param: string  $secret  The Base32-encoded secret key
param: string  $code    The passcode to check
return: boolean True if the code is valid

getCode($secret, $time = null)   X-Ref
Gets the TOTP passcode for a given secret key $secret and a given UNIX
timestamp $time

param: string  $secret  The Base32-encoded secret key
param: int     $time    UNIX timestamp
return: string

hashToInt($bytes, $start)   X-Ref
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

getUrl($user, $hostname, $secret)   X-Ref
Returns a QR code URL for easy setup of TOTP apps like Google Authenticator

param: string  $user      User
param: string  $hostname  Hostname
param: string  $secret    Secret string
return: string

generateSecret()   X-Ref
Generates a (semi-)random Secret Key for TOTP generation

return: string



Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer