PGP Word List

Packagist GitLab GitHub Bitbucket Gitea

PGP Word List encoder and decoder library for PHP.

Installation

composer require arokettu/pgp-word-list

Documentation

Encoding

PGP Word List algorithm encodes binary data by assigning an English word to every byte:

<?php

\Arokettu\PgpWordList\PgpWordList::encode('test test');
// "indoors glossary hockey hydraulic bison hydraulic fracture hurricane indoors"

Decoding

Decoding will succeed if words are given for the correct odd/even positions:

<?php

\Arokettu\PgpWordList\PgpWordList::decode(
    'indoors glossary hockey hydraulic bison hydraulic fracture hurricane indoors'
);
// 'test test'
\Arokettu\PgpWordList\PgpWordList::decode(
    'hydraulic glossary hockey indoors bison indoors fracture hurricane hydraulic'
);
// failure!!!

The string is case insensitive and space insensitive:

<?php

\Arokettu\PgpWordList\PgpWordList::decode(' InDoors    glossary  HOCKEY   hydraulic   ');
// 'test'

Use fuzzy param (Levenshtein distance value) to try to correct typos (do not use values more than 2-3):

<?php

\Arokettu\PgpWordList\PgpWordList::decode('inndoors glosary hokkey hydrolic', 2);
// 'test'

License

The library is available as open source under the terms of the MIT License.