geekish / faker-horse-battery-staple
Correct Horse Battery Staple password provider for Faker
Package info
github.com/geekish/faker-horse-battery-staple
pkg:composer/geekish/faker-horse-battery-staple
Requires
- php: ^8.0
- fakerphp/faker: ^1.11.0
Requires (Dev)
- phpunit/phpunit: ^10.5.35
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2026-05-28 19:07:21 UTC
README
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.
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
- Hannah Chartier
- Matt for the package upon which this was originally built.
- All Contributors
License
The MIT License (MIT). Please see License File for more information.