pragmarx / recovery
为两步验证创建恢复代码
v0.2.1
2021-08-15 12:26 UTC
Requires
- php: >=7.0
- pragmarx/random: ~0.1
Requires (Dev)
- phpunit/phpunit: >=5.4.3
- squizlabs/php_codesniffer: ^2.3
- tightenco/collect: ^5.0
Suggests
- tightenco/collect: Allows to generate recovery codes as collections
This package is auto-updated.
Last update: 2024-09-15 19:25:56 UTC
README
生成恢复/备份代码,为用户提供一种从丢失的两步验证或其任何问题中恢复的方式。
安装
通过Composer
$ composer require pragmarx/recovery
使用方法
基本数组使用
$this->recovery = new PragmaRX\Recovery(); $this->recovery->toArray();
集合
如果您正在使用Laravel或安装类似Collect的包,您可以使用
$this->recovery->toCollection();
您还可以定义一个不同的集合函数用于使用
$this->recovery->collectionFunction('alternateCollection'); $this->recovery->setCount(8)->toCollection();
JSON结果
$this->recovery->toJson();
应该给您
[ "C0r2Xp4o1v-oG3pteKXw3", "oLuSmVeJ7D-t4wnJVwkuC", "XdPXXJy3J6-Gl3d0EwWt7", "Bn8twjUJRt-Lv3KaAFwjR", "SrnMagyGRg-eC7WPyFQ17", "mRO4WPJpRN-hgfrUZqqZd", "xBZtyFOrJZ-Tbpg0pSvzf", "eiPFmwvJp0-oSqdNKclDH" ]
更改结果值/大小
$this->recovery ->setCount(8) // Generate 8 codes ->setBlocks(5) // Every code must have 7 blocks ->setChars(16) // Each block must have 16 chars ->toArray();
应该给您
[ "0ldZb4vhamHEd8B3-Tmri54Lb0t52wefR-gbJaHTN44O9C1igf-HRdF185SXxDwcdRf", "sFyrtezhjbFhCube-MszCKzvdsNL7QEY1-IY5OtpsFqM5d7jA7-t2mjCViRMHcMDdNZ", "bjKMlcsPhNrpFpSN-IbJR2ebOeXCxXVVb-omZLu3Ki9ImIEqZh-1sK74zOADl86GGRs", "wpa23eFj8PJcPdMG-E8A4LCwmd8iF8jt4-bVi2ltUEv29zoPJJ-pSetq2GD6euvZ9RA", "EJ3SRDQlddr2e2hT-eF79n1lqndwhRM7G-HrjHEVyA9zHSLi8g-TrHzl5oaqPi1NgCT", "lL7p4zjFxhQLND24-MEV1lmmyEKObjhhT-ldRWbOEnJLjBHmuc-Iex10bYAZ3NBljo2", "uomVxkrjGYqOqmdm-AtI9MiqFEJjTlSRi-AUNEwwUfrJVP5iaH-uyrsFCrqzC3WcaAa" ]
数字或字母?
$this->recovery ->numeric() // Generate numeric only codes ->toArray(); $this->recovery ->alpha() // Get back to default alpha generation ->toArray();
大写、小写和混合大小写
$this->recovery ->lowercase() // All lower ->toArray(); $this->recovery ->uppercase() // All upper ->toArray(); $this->recovery ->mixedcase() // Get back to default mixed case ->toArray();
块分隔符
通常使用-
作为块分隔符,但您可以用以下方式更改它
$this->recovery->setBlockSeparator('|')->toJson();
变更日志
请参阅CHANGELOG以获取有关最近更改的更多信息。
测试
$ composer update $ vendor/bin/phpunit
贡献
请参阅CONTRIBUTING以获取详细信息。
安全性
如果您发现任何与安全性相关的问题,请通过[email protected]发送电子邮件,而不是使用问题跟踪器。
致谢
许可协议
MIT许可协议(MIT)。有关更多信息,请参阅许可文件。