diff options
author | Christian Riesen <chris.riesen@gmail.com> | 2017-03-16 16:46:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-16 16:46:10 +0100 |
commit | f29c9eb9f9a7117a9e9912dac2f474120061260d (patch) | |
tree | ec9bb9249ab8e40ec76764f7b1b1835cb73f2873 /example | |
parent | 83f941e1ad6f7a2ff318e30cbf5b3219e63a9a62 (diff) | |
parent | 34bcbead1414383a0f2fc98fabf98acd2b9a3ae8 (diff) | |
download | otp-master.zip otp-master.tar.gz otp-master.tar.bz2 |
Merge pull request #18 from fkooman/random_compatHEAD2.4.0origin/masterorigin/HEADmaster
use paragonie/random_compat
Diffstat (limited to 'example')
-rw-r--r-- | example/index.php | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/example/index.php b/example/index.php index 4da362c..e5e9b7f 100644 --- a/example/index.php +++ b/example/index.php @@ -6,7 +6,7 @@ require_once __DIR__ . '/../vendor/autoload.php'; use Otp\Otp; use Otp\GoogleAuthenticator; -use Base32\Base32; +use ParagonIE\ConstantTime\Encoding; // Getting a secret, either by generating or from storage // DON'T use sessions as storage for this in production!!! @@ -25,7 +25,7 @@ if (strlen($secret) != 16) { // To use it in totp though we need to decode it into the original $otp = new Otp(); -$currentTotp = $otp->totp(Base32::decode($secret)); +$currentTotp = $otp->totp(Encoding::base32DecodeUpper($secret)); $qrCode = GoogleAuthenticator::getQrCodeUrl('totp', 'otpsample@cr', $secret); $keyUri = GoogleAuthenticator::getKeyUri('totp', 'otpsample@cr', $secret); @@ -79,7 +79,7 @@ if (isset($_POST['otpkey'])) { if (strlen($key) == 6) { // Remember that the secret is a base32 string that needs decoding // to use it here! - if ($otp->checkTotp(Base32::decode($secret), $key)) { + if ($otp->checkTotp(Encoding::base32DecodeUpper($secret), $key)) { echo 'Key correct!'; // Add here something that makes note of this key and will not allow // the use of it, for this user for the next 2 minutes. This way you |