The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Encode::Wordlist::PGP - encode/decode hex values using the PGP Word List

DESCRIPTION

The PGP Word List is a list of words for conveying data bytes in a clear unambiguous way via a voice channel. They are analogous in purpose to the NATO phonetic alphabet used by pilots, except a longer list of words is used, each word corresponding to one of the 256 unique numeric byte values. This module provides functions to convert between those byte values and words.

ALGORITHM

The list of words is actually two lists, each containing 256 phonetically distinct words, in which each word represents a different byte value between 0 and 255. Two lists are used because reading aloud long random sequences of human words usually risks three kinds of errors: transposition of two consecutive words, duplicate words, or omitted words. To detect all three kinds of errors, the two lists are used alternately for the even-offset bytes (including zero) and the odd-offset bytes in the byte sequence. Each byte value is actually represented by two different words, depending on whether that byte appears at an even or an odd offset from the beginning of the byte sequence. The two lists are readily distinguished by the number of syllables; the even list has words of two syllables, the odd list has three.

SYNOPSIS

    use Encode::Wordlist::PGP qw(:all); # pgp_wordlist_encode(), pgp_wordlist_decode()
    
    my $fingerprint = "4155 9711 308F 2A21 B9D5  072D 6219 58AF CB50 B5F9"; # this is the author's GPG fingerprint
    
    print join(" ", pgp_wordlist_encode($fingerprint));
    
    my $text_version = qq(cranky equipment preshrunk Babylon chairlift
    midsummer brickyard Camelot sentence specialist ahead clergyman flagpole
    bottomless endorse pharmacy spheroid embezzle scorecard Waterloo);

    print pgp_wordlist_decode($text_version);
    

METHODS

pgp_wordlist_encode

    print join(" ", pgp_wordlist_encode($fingerprint));
    # prints something like "cranky equipment preshrunk Babylon chairlift midsummer brickyard Camelot [...]"

Takes a string, which may only contain the letters A-F, the digits 0-9, spaces, and hyphens. Case-insensitive. Any spaces and hyphens (used to separate bytes for human readability) will be stripped out before processing. Returns an array of words. Hex bytes in the input must contain two digits each; method will die if the input string contains an odd number of characters.

pgp_wordlist_decode

   print pgp_wordlist_decode($text_version);
   # prints something like "41559711308F2A21B9D5072D621958AFCB50B5F9"
   

Takes a string, which may only contain letters, spaces, hyphens, \r and \n. Case-insensitive. Hyphens and \r and \n will be converted to spaces before processing; the number of spaces between each word does not matter. Will die if a non-wordlist word is encountered, or a word has the wrong number of syllables for its position (see ALGORITHM, above).

AUTHOR

Earle Martin <hex@cpan.org>

COPYRIGHT

This code is free software and is licensed under the same terms as the latest released version of Perl itself. You may redistribute it and/or modify it according to those conditions.

The encoding method in this module is derived from "fingerprint.pl" by Josh Larios (http://staff.washington.edu/jdlarios/fingerprint_pl.txt).

Portions of this documentation are taken from the Wikipedia article "PGP word list" (revision used available at http://xrl.us/pgpwordlist204668808). This documentation is licensed under the GNU Free Documentation License (http://www.gnu.org/copyleft/fdl.html).

The word list itself is copyrighted under a copyright owned by PGP Corporation, and licensed by them under the GNU Free Documentation License.

SEE ALSO