pgp_wordlist v0.1.0 PgpWordlist View Source
Toolset for working with the PGP word list. Allows converting hex to / from words.
The word list itself belongs to PGP Corporation.
Link to this section Summary
Functions
Converts a 2 digit hex string (with uppercase letters) and even / odd position into a word on the PGP word list.
Converts an even length hex string to list of words
Converts a word to a hex based on the PGP word list.
Converts a list of words to hex based on the PGP word list
Link to this section Functions
Converts a 2 digit hex string (with uppercase letters) and even / odd position into a word on the PGP word list.
pos
is based on whether the hex appears at an even or odd index rem(INDEX, 2)
Examples
iex> PgpWordlist.hex_to_word("00", 0)
"aardvark"
iex> PgpWordlist.hex_to_word("00", 1)
"adroitness"
iex> PgpWordlist.hex_to_word("FF", 0)
"Zulu"
iex> PgpWordlist.hex_to_word("FF", 1)
"Yucatan"
iex> PgpWordlist.hex_to_word("1", 1)
** (ArgumentError) Hex must be 2 bytes long ('01' instead of '1')
Converts an even length hex string to list of words
Examples
iex> PgpWordlist.hex_to_words("00")
["aardvark"]
iex> PgpWordlist.hex_to_words("E582")
["topmost", "Istanbul"]
iex> PgpWordlist.hex_to_words("82E5")
["miser", "travesty"]
iex> PgpWordlist.hex_to_words("00F")
** (ArgumentError) Hex must be an even amount of bytes long
Converts a word to a hex based on the PGP word list.
Will handle different cases of words and return hex with uppercase letters.
Examples
iex> PgpWordlist.word_to_hex("AARDVARK")
"00"
iex> PgpWordlist.word_to_hex("aardvark")
"00"
iex> PgpWordlist.word_to_hex("AardVaRk")
"00"
iex> PgpWordlist.word_to_hex("woodlark")
"FE"
Converts a list of words to hex based on the PGP word list
Examples
iex> PgpWordlist.words_to_hex(["topmost", "Istanbul", "Pluto", "vagabond"])
"E58294F2"
iex> PgpWordlist.words_to_hex(["miser", "travesty"])
"82E5"