PHPackages                             yaman-shahbander-dev/totp-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. yaman-shahbander-dev/totp-generator

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

yaman-shahbander-dev/totp-generator
===================================

A PHP implementation of Time-Based One-Time Password (TOTP), using Base32 encoding and HMAC hashing. Generates and verifies OTPs for secure authentication.

v1.1.1(1y ago)22MITPHPPHP ^7.2|^8.0

Since May 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/yaman-shahbander-dev/laravel-totp)[ Packagist](https://packagist.org/packages/yaman-shahbander-dev/totp-generator)[ RSS](/packages/yaman-shahbander-dev-totp-generator/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (5)Used By (0)

laravel-totp
============

[](#laravel-totp)

A Laravel package for generating and verifying Time-Based One-Time Passwords (TOTP) compatible with RFC 6238. Provides both facade and contract-based implementations.

Features
========

[](#features)

- Generate TOTP codes
- Verify TOTP codes with configurable window
- Base32 encoding/decoding utilities
- Configurable parameters (period, digits, verification window)
- Laravel facade and service provider integration

Installation
============

[](#installation)

- Install via Composer:

```
composer require yaman-shahbander-dev/laravel-totp
```

- Publish the configuration file (optional):

```
php artisan vendor:publish --provider="TotpGenerator\Providers\TotpServiceProvider" --tag="config"
```

Configuration
=============

[](#configuration)

Default values in config/totp.php:

```
'default_period' => 30,      // Time step in seconds
'default_digits' => 6,       // Number of digits in OTP
'verification_window' => 1,  // Number of periods to check before/after
```

Usage
=====

[](#usage)

Using the Facade

```
use TotpGenerator\Facades\Totp;

// Generate a random secret (store this securely)
$secret = Str::random(16);
$base32Secret = Totp::encodeBase32($secret);

// Generate current TOTP
$code = Totp::generate($base32Secret);

// Verify a code
$isValid = Totp::verify($userCode, $base32Secret);

// With custom window
$isValid = Totp::verify($userCode, $base32Secret, 2);
```

Using Dependency Injection

```
use TotpGenerator\Contracts\TotpGeneratorContract;

class AuthController {
    public function __construct(
        protected TotpGeneratorContract $totp
    ) {}

    public function verifyCode(Request $request)
    {
        $isValid = $this->totp->verify(
            $request->code,
            $user->totp_secret
        );
    }
}
```

Direct Usage

```
$totp = app(TotpGeneratorContract::class);
$code = $totp->generate($base32Secret);
```

Base32 Utilities

```
// Encode binary to Base32
$base32Secret = Totp::encodeBase32(random_bytes(16));

// Decode Base32 to binary
$binarySecret = Totp::decodeBase32($base32Secret);
```

Security Considerations
=======================

[](#security-considerations)

- Always store secrets securely (encrypted at rest)
- Use secure random bytes for secret generation
- Consider rate limiting verification attempts
- The package uses SHA-1 by default (compatible with most authenticator apps)

License
=======

[](#license)

MIT License (see [LICENSE](https://mit-license.org/) file)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance46

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

414d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ceebd7147cba8294aa8332c7b293e134900dd3e8c77cb3272ef83dee7c254250?d=identicon)[yaman-shahbander-dev](/maintainers/yaman-shahbander-dev)

---

Top Contributors

[![mohamad-yaman-shahbandar](https://avatars.githubusercontent.com/u/154523997?v=4)](https://github.com/mohamad-yaman-shahbandar "mohamad-yaman-shahbandar (1 commits)")[![yaman-shahbander-dev](https://avatars.githubusercontent.com/u/154523997?v=4)](https://github.com/yaman-shahbander-dev "yaman-shahbander-dev (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yaman-shahbander-dev-totp-generator/health.svg)

```
[![Health](https://phpackages.com/badges/yaman-shahbander-dev-totp-generator/health.svg)](https://phpackages.com/packages/yaman-shahbander-dev-totp-generator)
```

###  Alternatives

[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[illuminate/auth

The Illuminate Auth package.

10528.2M1.2k](/packages/illuminate-auth)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
