pear / text_password
更多信息请访问:http://pear.php.net/package/Text_Password
1.2.2
2022-08-10 16:04 UTC
Requires
- php: >=5.2.1
- pear/pear_exception: *
Requires (Dev)
- phpunit/phpunit: ^9.0.0
This package is auto-updated.
Last update: 2024-09-10 20:43:14 UTC
README
提供各种密码生成类型的类。
用法
在Web应用程序中,生成密码是一个非常常见的任务。此包提供了一个易于使用且直观的API来生成
- 可发音的密码
- 不可发音的密码
- 基于给定字符串的密码
对于最后一点,支持多种简单 混淆 算法。
创建可发音的密码
<?php require_once 'Text/Password.php'; // Create pronouncable password of 10 characters. echo Text_Password::create() . "\n"; // Create 3 different pronouncable passwords of length 8. print_r(Text_Password::createMultiple(3, 8)); ?>
创建不可发音的密码
<?php require_once 'Text/Password.php'; // Create unpronounceable password of length 8 with a, b, and c as // possible characters. echo Text_Password::create(8, 'unpronounceable', 'abc') . "\n"; // Create 4 different unpronounceable passwords of length 10. print_r(Text_Password::createMultiple(4, 10, 'unpronounceable')); // Creating unpronounceable password of 8 chars with only alphanumeric // characters. Other classes that can be specified are 'numeric', 'alphabetic' // and '' for all characters. echo Text_Password::create(8, 'unpronounceable', 'alphanumeric') . "\n"; ?>
基于给定字符串创建密码
<?php require_once 'Text/Password.php'; // Create password from login 'olivier', type is 'reverse'. Other supported // types are: // // - 'rot13' // - 'rotx' // - 'rotx++', // - 'rotx--', // - 'xor', // - 'ascii_rotx', // - 'ascii_rotx++', // - 'ascii_rotx--', // - 'shuffle', echo Text_Password::createFromLogin('olivier', 'reverse') . "\n"; // Create multiple passwords from array of logins. $logins = array('olivier', 'martin', 'vanhoucke', 'jansen'); print_r(Text_Password::createMultipleFromLogin($logins, 'reverse')); ?>
安装
PEAR
pear install Text_Password
Composer
./composer.phar require pear/text_password