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


Encode-Wordlist-PGP documentation  | view source Contained in the Encode-Wordlist-PGP distribution.

Index


NAME

Top

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

DESCRIPTION

Top

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

Top

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

Top

    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

Top

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

Top

Earle Martin <hex@cpan.org>

COPYRIGHT

Top

SEE ALSO

Top

* http://en.wikipedia.org/wiki/PGP_word_list
* GnuPG::Fingerprint
* Digest::BubbleBabble - a similar concept for message digests
* Lingua::Alphabet::Phonetic

Encode-Wordlist-PGP documentation  | view source Contained in the Encode-Wordlist-PGP distribution.