\FOFEncryptTotp
This class provides an RFC6238-compliant Time-based One Time Passwords, compatible with Google Authenticator (with PassCodeLength = 6 and TimePeriod = 30).
Synopsis
class FOFEncryptTotp
{
- // members
- private $_passCodeLength;
- private $_pinModulo;
- private $_secretLength;
- private $_timeStep;
- private $_base32;
- // methods
- public void __construct()
- public int getPeriod()
- public boolean checkCode()
- public string getCode()
- protected string hashToInt()
- public string getUrl()
- public string generateSecret()
Members
private
- $_base32
- $_passCodeLength
- $_pinModulo
- $_secretLength
- $_timeStep
Methods
protected
- hashToInt() — Extracts a part of a hash as an integer
public
- __construct() — 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.
- checkCode() — Check is the given passcode $code is a valid TOTP generated using secret key $secret
- generateSecret() — Generates a (semi-)random Secret Key for TOTP generation
- getCode() — Gets the TOTP passcode for a given secret key $secret and a given UNIX timestamp $time
- getPeriod() — 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.
- getUrl() — Returns a QR code URL for easy setup of TOTP apps like Google Authenticator