bonabrian/laravel-otp 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bonabrian/laravel-otp

Composer 安装命令:

composer require bonabrian/laravel-otp

包简介

Laravel OTP generator and validator without using database

README 文档

README

Github License

Installation

Via Composer

composer require bonabrian/laravel-otp

To publish the config file for laravel

php artisan otp:publish

Usage in Laravel

Import the facade class

use Bonabrian\Otp\Facades\Otp;

Generate an OTP:

$code = Otp::generate($secret);

The generated OTP above will only be validated using the same secret within the default expiry time.

TIP: OTP is generally used for verification. So the easiest way of determining the secret is the user's email/username or phone number or maybe user ID.

Validate an OTP:

$valid = Otp::validate($code, $secret);

Other Generate & Validate options:

// Generate
Otp::setDigits(4)->generate($secret); // 4 Digits
Otp::setExpiry(30)->generate($secret); // 30 min expiry
Otp::setDigits(4)->setExpiry(30)->generate($secret); // 4 Digits, 30 min expiry

Make sure to set the same config during validating. Example:

// Example 1
Otp::validate($code, $secret); // false
Otp::setDigits(4)->validate($code, $secret); // true

// Example 2
Otp::validate($code, $secret); // false
Otp::setExpiry(30)->validate($codde, $secret); // true

// Example 3
Otp::validate($code, $secret); // false
Otp::setDigits(4)->setExpiry(30)->validate($code, $secret); // true

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固