jc5 / recovery
为双因素认证创建恢复代码
v2.2.0
2022-03-31 05:55 UTC
Requires
- php: >=8.0
- ext-json: *
- 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
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)。请参阅许可文件以获取更多信息。