geekish/faker-horse-battery-staple

Correct Horse Battery Staple password provider for Faker

Maintainers

Package info

github.com/geekish/faker-horse-battery-staple

pkg:composer/geekish/faker-horse-battery-staple

Statistics

Installs: 22

Dependents: 0

Suggesters: 0

Stars: 3

Open Issues: 0

3.0 2026-05-28 19:02 UTC

This package is auto-updated.

Last update: 2026-05-28 19:07:21 UTC


README

Latest Version on Packagist Total Downloads

Generate correct-horse-battery-staple passwords with Faker. Uses a modified version of the 10000 words list.

This package is intended to be used for testing purposes only. The CHBS is indeed a good method to use to generate passwords, but there are plenty of other tools like correcthorsebatterystaple.net that you can use.

XKCD comic

Install

Via Composer

composer require geekish/faker-horse-battery-staple

Usage

Add the provider:

use Faker\Generator;
use Geekish\FakerHorseBatteryStaple\BatteryStapleProvider;

$faker = new Generator();
$faker->addProvider(new BatteryStapleProvider($faker));

Without any arguments, a random 3-word password is generated with no delimiter (character(s) separating words); e.g. correcthorsebattery.

echo $faker->correctHorseBatteryStaple;

To specify delimiter, e.g. (correct.horse.battery):

echo $faker->correctHorseBatteryStaple(delimiter: '.');

There isn't a character limit so if you really want to, you can do something like:

echo $faker->correctHorseBatteryStaple(delimiter: '!@#$%^&*');

But I'm not sure why you would want to do that.

To specify number of words:

echo $faker->correctHorseBatteryStaple(words: 7);

Again, no limit, but 3+ is best.

To capitalize a random word:

echo $faker->correctHorseBatteryStaple(capitalize: true);

All arguments, with their default values:

echo $faker->correctHorseBatteryStaple(
  delimiter: '',
  words: 3,
  capitalize: false
);

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email hannah@sent.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.