https://github.com/ericmann/totp
A PHP library for TOTP support in PHP 7.2+.
https://github.com/ericmann/totp
totp
Last synced: 11 months ago
JSON representation
A PHP library for TOTP support in PHP 7.2+.
- Host: GitHub
- URL: https://github.com/ericmann/totp
- Owner: ericmann
- License: mit
- Created: 2017-11-19T17:54:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-16T20:52:01.000Z (almost 2 years ago)
- Last Synced: 2025-03-29T22:51:13.644Z (about 1 year ago)
- Topics: totp
- Language: PHP
- Homepage:
- Size: 71.3 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# TOTP ![PHP 7.4+][php-image] [![Build Status][build-image]][build-url] [![PHPStan][phpstan-image]][phpstan-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Packagist][packagist-image]][packagist-url]
A PHP library for generating one-time passwords according to [RFC-6238](http://tools.ietf.org/html/rfc6238) for time-based OTP generation.
This library is compatible with Google Authenticator apps available for Android and iPhone.
## Quick Start
Use [Composer](https://getcomposer.org/) to add `ericmann/totp` to your project.
```php
require __DIR__ . '/vendor/autoload.php';
// Create a new, random token
$token = new EAMann\TOTP\Key();
// Import a known token
$raw = '...';
$token = EAMann\TOTP\Key::import($raw);
// Validate an OTP against a token
if (EAMann\TOTP\is_valid_auth_code($token, $otp)) {
// ...
}
```
[php-image]: https://img.shields.io/badge/php-7.4%2B-green.svg
[packagist-image]: https://img.shields.io/packagist/dt/ericmann/totp.svg
[packagist-url]: https://packagist.org/packages/ericmann/totp
[phpstan-image]: https://github.com/ericmann/totp/actions/workflows/analysis.yml/badge.svg
[phpstan-url]: https://github.com/ericmann/totp/actions/workflows/analysis.yml
[build-image]: https://github.com/ericmann/totp/actions/workflows/build.yml/badge.svg
[build-url]: https://github.com/ericmann/totp/actions/workflows/build.yml
[coveralls-image]: https://coveralls.io/repos/github/ericmann/totp/badge.svg?branch=master
[coveralls-url]: https://coveralls.io/github/ericmann/totp?branch=master