plusforta / password-generator
PHP library for generating easy to remember but hard to guess passwords
Installs: 297
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
pkg:composer/plusforta/password-generator
Requires
- php: ^8.3
Requires (Dev)
- laravel/pint: ^1.25
- phpunit/phpunit: ^11.0
- rector/rector: ^2.2
This package is auto-updated.
Last update: 2025-12-24 12:25:50 UTC
README
A flexible and scriptable password generator which generates strong passphrases, inspired by XKCD Comic 936. Generated passwords easy to remember, but hard to guess passwords.
Note: This is a modernized fork of the original password-generator by 27cm/KarelWintersky, updated for PHP 8.3+ compatibility.
Installing
With Composer:
$ composer require plusforta/password-generator
Basic usage
Library generates phrases from frequently used words:
- English phrases (example "throat-fast-only-idea")
- German phrases (example "laut-welt-ganze-liter")
Generate password with default length (4 words) and default separator (dash).
use Plusforta\Password\Generator;
// Generate English password (default: 4 words with dash separator)
echo Generator::generateEn();
// => "throat-fast-only-idea"
// Generate German password (default: 4 words with dash separator)
echo Generator::generateDe();
// => "laut-welt-ganze-liter"
// Custom length
echo Generator::generateEn(6);
// => "ritual-error-raise-arab-tail-happy"
// Custom separator (space)
echo Generator::generateEn(4, ' ');
// => "throat fast only idea"
// Custom separator (underscore)
echo Generator::generateDe(4, '_');
// => "laut_welt_ganze_liter"
Exporting word lists
You can access and export the complete word list from any WordList class:
use Plusforta\Password\WordList\En;
use Plusforta\Password\WordList\De;
// Get all words from English word list
$en = new En();
$allWords = $en->getWords();
// => array of 2048 English words
// Get all words from German word list
$de = new De();
$allWords = $de->getWords();
// => array of 2048 German words
// Filter words by prefix (case-insensitive)
$wordsStartingWithAn = $en->getWords('an');
// => array of words starting with "an" (e.g., "and", "animal", "answer")
// Uppercase prefix works the same way
$sameWords = $en->getWords('AN');
// => same result as lowercase "an"
// Export to JSON
echo json_encode($en->getWords());
// Export words starting with specific prefix
echo json_encode($en->getWords('pre'));
Word lists
English
List of 2048 most frequently used English words.
| Class | Comment | Word lenghth | Example |
|---|---|---|---|
| WordList\En | all words | 4-6 | have, that |
| WordList\En\Nouns | nouns | 4-6 | time, year |
| WordList\En\Verbs | verbs | 4-6 | have, would |
| WordList\En\Adjectives | adjectives | 4-8 | other, good |
German
List of 2048 most frequently used German words (source). Words with diacritic letters (ä, ö, ü) and eszett (ß) excluded.
| Class | Comment | Word lenghth | Example |
|---|---|---|---|
| WordList\De | all words | 4-6 | sich, nicht |
Security
Library uses CSPRNG for random number generation.
