承接 elephant-php/otp 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

elephant-php/otp

最新稳定版本:0.1.0

Composer 安装命令:

composer require elephant-php/otp

包简介

A small PHP library for generating one-time passwords and random verification codes.

README 文档

README

elephant-php

Elephant OTP

A small PHP library for generating one-time passwords and random verification codes.

Latest Version License PHP 8.3+


Installation

composer require elephant-php/otp

Usage

Generate a default 6-character code:

use Elephant\Otp\OtpCode;

$code = new OtpCode()->generate();

Generate a code with a custom length:

use Elephant\Otp\OtpCode;

$code = new OtpCode()->generate(12);

Choose an alphabet:

use Elephant\Otp\Alphabet;
use Elephant\Otp\OtpCode;

$otp = new OtpCode();

$numeric = $otp->generate(alphabet: Alphabet::Numeric);      // 483920
$hex = $otp->generate(16, Alphabet::Hex);                    // 9f03a8c12b4e70df
$readable = $otp->generate(10, Alphabet::Readable);          // 7h4qz9x2wa

Alphabets

Alphabet Characters
Alphabet::Numeric 0123456789
Alphabet::Hex 0123456789abcdef
Alphabet::Alpha abcdefghijklmnopqrstuvwxyz
Alphabet::AlphaNumeric abcdefghijklmnopqrstuvwxyz0123456789
Alphabet::Readable 23456789abcdefghijkmnpqrstuvwxyz

Alphabet::Readable excludes visually ambiguous characters such as 0, 1, l, and o.

Invalid Length

Code length must be at least 1. Invalid lengths throw InvalidArgumentException:

use Elephant\Otp\OtpCode;

new OtpCode()->generate(0); // throws InvalidArgumentException

Testing

composer test

License

MIT License.

Please see LICENSE for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固