PHPackages                             blar/otp - 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. [Security](/categories/security)
4. /
5. blar/otp

ActiveLibrary[Security](/categories/security)

blar/otp
========

OTP for PHP

06PHP

Since Mar 9Pushed 10y ago1 watchersCompare

[ Source](https://github.com/blar/otp)[ Packagist](https://packagist.org/packages/blar/otp)[ RSS](/packages/blar-otp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![License](https://camo.githubusercontent.com/f4a4c4f7866c9cbd6d65b70575892d072e8d72b7a1d54513fdeb93d8f091a375/68747470733a2f2f706f7365722e707567782e6f72672f626c61722f6f74702f6c6963656e7365)](https://packagist.org/packages/blar/otp)[![Latest Stable Version](https://camo.githubusercontent.com/a4becbd7c43c78167179e8f4d510ba086d9427ef07719ad23ccdc9b375d60817/68747470733a2f2f706f7365722e707567782e6f72672f626c61722f6f74702f762f737461626c65)](https://packagist.org/packages/blar/otp)[![Build Status](https://camo.githubusercontent.com/2f087895684036146b0aa29fe1a05b825c0a0c167de9db070c492c26a8033495/68747470733a2f2f7472617669732d63692e6f72672f626c61722f6f74702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/blar/otp)[![Coverage Status](https://camo.githubusercontent.com/7a3b382e8da65888a59ca3a8a4a9de3fe587e326aac4e73d78cc62a79b8f9c6e/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f626c61722f6f74702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/blar/otp?branch=master)[![Dependency Status](https://camo.githubusercontent.com/3dc75cefcdf748a3857fb25d408f4890eb752cdb2c76dce3119cf89eb2c933d4/68747470733a2f2f67656d6e617369756d2e636f6d2f626c61722f6f74702e737667)](https://gemnasium.com/blar/otp)[![Flattr](https://camo.githubusercontent.com/41a1a68906b7f18eaf2c372bc091deadd3c688cc10a1db2ea9494180539265db/68747470733a2f2f627574746f6e2e666c617474722e636f6d2f666c617474722d62616467652d6c617267652e706e67)](https://flattr.com/submit/auto?user_id=Blar&url=https%3A%2F%2Fgithub.com%2Fblar%2Fotp)

One Time Password (OTP)
=======================

[](#one-time-password-otp)

„Time based“ One Time Password erstellen
----------------------------------------

[](#time-based-one-time-password-erstellen)

### Setup

[](#setup)

```
$otp = new Totp();
$otp->setLabel('username@example.com');
$otp->setIssuer('example.com');

```

### Secret erstellen

[](#secret-erstellen)

Das Secret muss nur einmal pro Benutzer erstellt werden.

```
$secret = $otp->createSecret();

```

### Secret zuweisen

[](#secret-zuweisen)

```
$otp->setSecret($secret);

```

### OTP-URL ausgeben

[](#otp-url-ausgeben)

```
$otp->getUrl();

```

Die Url sieht dann z.B. so aus:

```
otpauth://totp/username@example.com?
    issuer = example.com
    algorithm = SHA1
    digits = 6
    period = 30
    secret = LWZU3NR3PN5FXUX6XTHWE7OIWJEAFTWC

```

### OTP-URL als QRCode ausgeben

[](#otp-url-als-qrcode-ausgeben)

Einige Authenticator unterstützen die Übertragung der Einstellungen durch das Scannen eines QRCodes. So ein QRCode kann z.B. mit dem Paket [blar/google-charts](https://github.com/blar/google-charts/) erstellt werden.

```
$qrcode = new Qrcode();
$qrcode->setSize(256, 256);
$qrcodeUrl = $qrcode->createUrl($otp->getUrl());

```

### Passwort prüfen

[](#passwort-prüfen)

```
$otp->validate($_POST['otp']);

```

Google-Authenticator
--------------------

[](#google-authenticator)

Für den Google-Authenticator müssen folgende Einstellungen vorgenommen werden, da dieser für einige Einstellungen Standardwerte verwendet die nicht über die otpauth-URL geändert werden können.

```
$otp->setAlgorithm('SHA1');
$otp->setDigits(6);
$otp->setInterval(30);

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/111508?v=4)[Andreas Treichel](/maintainers/blar)[@blar](https://github.com/blar)

---

Top Contributors

[![blar](https://avatars.githubusercontent.com/u/111508?v=4)](https://github.com/blar "blar (4 commits)")

### Embed Badge

![Health badge](/badges/blar-otp/health.svg)

```
[![Health](https://phpackages.com/badges/blar-otp/health.svg)](https://phpackages.com/packages/blar-otp)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[enlightn/security-checker

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

33732.2M110](/packages/enlightn-security-checker)

PHPackages © 2026

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