New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

adgodev/xkpasswd-php

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adgodev/xkpasswd-php

Memorable password generator

Source
Packagist
Version
v1.0.0
Version published
Total downloads
1.5K
Maintainers
1
Created
Source

xkpasswd

Memorable password generator, inspired by a PERL module powering xkpasswd.net/s/

Based heavily on the xkpasswd-node package. Also a nod to battery-staple for the inspiration.

Usage

You can use xkpasswd as a module in your application.

EXAMPLES

use Adgodev\Xkpasswd\Generator;

Generator::generate();

// valuable=bear=difference=53

Generator::generate([
    'complexity' => 5,
    'separators' => '#+-'
]);

// addition#wheat#congress#manner#lonely#20

Generator::generate([
    'wordList' => 'myWordList.json'
]);

// apple#grape#banana#40

Options

You can specify complexity argument in accordance with complexity levels table. Defaults to 2.

If specified pattern argument overrides the pattern derived from complexity level.

If separators are provided they are used instead of the standard set (see complexity levels). One separator is used per password, picked randomly from the provided set.

You can set transform option to alternate or uppercase to trigger case transformation.

To generate multiple passwords at once you can specify the desired amount with the number argument. Defaults to 1.

Finally if you'd like to use a custom list of words you can provide it as a JSON file, text file or an array via wordList function.

EXAMPLE Default behaviour

use Adgodev\Xkpasswd\Generator;

Generator::generate();

// hide+threw+money+61

EXAMPLE Specify complexity

use Adgodev\Xkpasswd\Generator;

Generator::generate([
    'complexity' => 5
]);

// join=industrial=wide=direction=lungs=16

Generator::generate([
    'complexity' => 6
]);

// 57!FIFTHLY!astronauts!AFFECTEDLY!nymphs!TRUSTLESSNESSES!06

EXAMPLE Specify custom pattern

use Adgodev\Xkpasswd\Generator;

Generator::generate([
    'pattern' => 'wdwd'
]);

// adjective3solar6

EXAMPLE Specify custom word list / dictionary

use Adgodev\Xkpasswd\Generator;

Generator::generate([
    'wordList' => 'myWordList.json'
]);

// orange.apple.banana
use Adgodev\Xkpasswd\Generator;

Generator::generate([
    'wordList' => 'myWordList.txt'
]);

// kiwi-strawberry-grape

Patterns

Patterns can consist of any combination of words, digits and separators. The first letters (w, d and s respectively) are used in pattern string provided to the password generation function.

For example:

  • w will return a single word (i.e. demographics). Use w for lowercase and W for uppercase.
  • wsd will return a word and a digit, separated by one of the permitted separators (i.e. storm#7)
  • wswsdd will return two words followed by a two digit number, all with separators between (i.e. delates+dissembled+16)

Complexity levels

There are 6 complexity levels specified which can be used to provide default patterns as well as trigger additional features, such as alternate casing between words and expanded sets of separators.

ComplexityPatternSeparators
1wsw#.-=+_
2wswsw#.-=+_
3wswswsdd#.-=+_
4wswswswsdd#.-=+_
5wswswswswsd#.-=+_!$*:~?
6ddswswswswswsdd#.-=+_!$*:~?%^&;

In addition level 6 alternates upper and lower case between words.

Release notes

v1.0.0

Initial release

Keywords

password

FAQs

Package last updated on 13 Mar 2020

Related posts