<commit_before># ![Logo](https://raw.githubusercontent.com/RobThree/TwoFactorAuth/master/logo.png) TwoFactorAuth class for PHP

PHP class for [two-factor (or multi-factor) authentication](http://en.wikipedia.org/wiki/Multi-factor_authentication) using [TOTP](http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm) and [QR-codes](http://en.wikipedia.org/wiki/QR_code). Inspired by, based on but most importantly an *improvement* on '[PHPGangsta/GoogleAuthenticator](https://github.com/PHPGangsta/GoogleAuthenticator)'.

<p align="center">
<img src="https://raw.githubusercontent.com/RobThree/TwoFactorAuth/master/multifactorauthforeveryone.png">
</p>

## Requirements

* Tested on PHP 5.3, 5.4, 5.5 and 5.6
* [cURL](http://php.net/manual/en/book.curl.php) when using the provided `GoogleQRCodeProvider` (default), `QRServerProvider` or `QRicketProvider` but you can also provide your own QR-code provider.
* [MCrypt](http://php.net/manual/en/book.mcrypt.php), [OpenSSL](http://php.net/manual/en/book.openssl.php) or [Hash](http://php.net/manual/en/book.hash.php) depending on which built-in RNG you use (TwoFactorAuth will try to 'autodetect' and use the best available); however: feel free to provide your own (CS)RNG.

## Usage

Here are some code snippets that should help you get started...

````php
// Start by including the TwoFactorAuth.php file which contains all you need (for now)
$tfa = new RobThree\TwoFactorAuth\TwoFactorAuth('My Company');
````

The TwoFactorAuth class constructor accepts 6 parameters (all optional):

Parameter         | Default value | Use 
------------------|---------------|--------------------------------------------------
`$issuer`         | `null`        | Will be displayed in the app as issuer name
`$digits`         | `6`           | The number of digits the resulting codes will be
`$period`         | `30`          | The number of seconds a code will be valid
`$algorithm`      | `sha1`        | The algorithm used<commit_msg>* Added composer instructions to readme<commit_after># ![Logo](https://raw.githubusercontent.com/RobThree/TwoFactorAuth/master/logo.png) TwoFactorAuth class for PHP

PHP class for [two-factor (or multi-factor) authentication](http://en.wikipedia.org/wiki/Multi-factor_authentication) using [TOTP](http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm) and [QR-codes](http://en.wikipedia.org/wiki/QR_code). Inspired by, based on but most importantly an *improvement* on '[PHPGangsta/GoogleAuthenticator](https://github.com/PHPGangsta/GoogleAuthenticator)'.

<p align="center">
<img src="https://raw.githubusercontent.com/RobThree/TwoFactorAuth/master/multifactorauthforeveryone.png">
</p>

## Requirements

* Tested on PHP 5.3, 5.4, 5.5 and 5.6
* [cURL](http://php.net/manual/en/book.curl.php) when using the provided `GoogleQRCodeProvider` (default), `QRServerProvider` or `QRicketProvider` but you can also provide your own QR-code provider.
* [MCrypt](http://php.net/manual/en/book.mcrypt.php), [OpenSSL](http://php.net/manual/en/book.openssl.php) or [Hash](http://php.net/manual/en/book.hash.php) depending on which built-in RNG you use (TwoFactorAuth will try to 'autodetect' and use the best available); however: feel free to provide your own (CS)RNG.

## Installation

Add the following line to the composer.json file:

````
{
    "require": {
        "robthree/twofactorauth": "~1.0"
    }
}
````

## Usage

Here are some code snippets that should help you get started...

````php
// Start by including the TwoFactorAuth.php file which contains all you need (for now)
$tfa = new RobThree\TwoFactorAuth\TwoFactorAuth('My Company');
````

The TwoFactorAuth class constructor accepts 6 parameters (all optional):

Parameter         | Default value | Use 
------------------|---------------|--------------------------------------------------
`$issuer`         | `null`        | Will be displayed in the app as issuer name
`$digits`         | `6`           | The number of digits the resulting codes will be
`$period`         | `30`          | The number of seconds a code will be valid
`$algorithm`      | `sha1`        | The algorithm used
{'fraction_non_alphanumeric': 0.16662641873943493, 'fraction_numerical': 0.006761651774933591, 'mean_word_length': 3.3645943097997892, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3121820', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1217, 'n_words': 358}