PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Text » Text_Password » Manual

Creating passwords with PHP.

Introduction

Introduction – Introduction to Text_Password

Introduction

Generating passwords is a very common task in web applications. This package provides an easy-to-use and intuitive API to generate

For the last point, multiple, simple "obfuscation" algorithms are supported.

Setup

Requirements

Text_Password requires PHP 4.2.0 or better.

Installation

The Text_Password package can be installed using the PEAR installer command pear install Text_Password.

Alternative installation methods for situations where one has no access to the pear installer command can be found in the general installation chapter.

Uninstallation

Uninstalling the package can be done with pear uninstall Text_Password.

Supported types of passwords

Supported types of passwords – This part of the documentation introduces the different supported types of passwords and gives examples for their usage.

Pronounceable passwords

One feature of the package is the ability to create passwords that are pronounceable using the static create() method. createMultiple() can be used to create several passwords at once.

Creating a pronounceable password:

<?php
require_once "Text/Password.php";

echo "Creating pronounceable password of 10 chars....: ";
echo Text_Password::create() . "\n\n";

echo "Creating 3 different pronounceable passwords...: ";
print_r(Text_Password::createMultiple(3));
?>

Unpronounceable passwords

In addition to pronounceable passwords Text_Password can also handle passwords that are not pronounceable.

Creating a unpronounceable password:

<?php
require_once "Text/Password.php";

echo "\nCreating unpronounceable password of 8 chars with a,b,c as possible chars....:\t";
echo Text_Password::create(8, 'unpronounceable', 'a,b,c') . "\n\n";

echo "\nCreating 4 different unpronounceable passwords...:\n";
print_r(Text_Password::createMultiple(4, 10, 'unpronounceable'));

echo "\nCreating unpronounceable password of 8 chars with numeric chars:\t";
echo Text_Password::create(8, 'unpronounceable', 'numeric') . "\n\n";

echo "\nCreating unpronounceable password of 8 chars with alphanumeric chars:\t";
echo Text_Password::create(8, 'unpronounceable', 'alphanumeric') . "\n\n";
?>

Passwords based on given strings

Text_Password provides the ability to create passwords that are based on a given string. In a lot of cases this string is a existing username for a authentication system.

Creating passwords based on a given string:

<?php
require_once "Text/Password.php";

echo "\nCreating password from login 'olivier', type is 'reverse':\t";
echo Text_Password::createFromLogin('olivier', 'reverse') . "\n\n";

echo "\nCreating password from login 'olivier', type is 'rot13':\t";
echo Text_Password::createFromLogin('olivier', 'rot13') . "\n\n";

echo "\nCreating password from login 'olivier', type is 'rotx':\t";
echo Text_Password::createFromLogin('olivier', 'rotx', 13) . "\n\n";

echo "\nCreating password from login 'olivier', type is 'rotx++':\t";
echo Text_Password::createFromLogin('olivier', 'rotx++', 13) . "\n\n";

echo "\nCreating password from login 'olivier', type is 'rotx--':\t";
echo Text_Password::createFromLogin('olivier', 'rotx--', 13) . "\n\n";

echo "\nCreating password from login 'olivier', type is 'xor':\t";
echo Text_Password::createFromLogin('olivier', 'xor', 5) . "\n\n";

echo "\nCreating password from login 'olivier', type is 'ascii_rotx':\t";
echo Text_Password::createFromLogin('olivier', 'ascii_rotx', 5) . "\n\n";

echo "\nCreating password from login 'olivier', type is 'ascii_rotx++':\t";
echo Text_Password::createFromLogin('olivier', 'ascii_rotx++', 5) . "\n\n";

echo "\nCreating password from login 'olivier', type is 'ascii_rotx--':\t";
echo Text_Password::createFromLogin('olivier', 'ascii_rotx--', 5) . "\n\n";

echo "\nCreating password from login 'olivier', type is 'shuffle':\t";
echo Text_Password::createFromLogin('olivier', 'shuffle', 1) . "\n\n";

echo "\nCreating password from an array of login 'olivier', 'martin', 'vanhoucke', 'jansen', type is 'reverse':\n";
$logins = array('olivier', 'martin', 'vanhoucke', 'jansen');
print_r(Text_Password::createMultipleFromLogin($logins, 'reverse'));
?>

Currently the following obfuscation algorithms are supported: