ciphers.polybius

A Polybius Square is a table that allows someone to translate letters into numbers.

https://www.braingle.com/brainteasers/codes/polybius.php

Attributes

SQUARE

Classes

PolybiusCipher

Module Contents

class ciphers.polybius.PolybiusCipher
decode(message: str) str

Return the decoded version of message according to the polybius cipher

>>> PolybiusCipher().decode("44154344 32154343112215") == "test message"
True
>>> PolybiusCipher().decode("4415434432154343112215") == "testmessage"
True
encode(message: str) str

Return the encoded version of message according to the polybius cipher

>>> PolybiusCipher().encode("test message") == "44154344 32154343112215"
True
>>> PolybiusCipher().encode("Test Message") == "44154344 32154343112215"
True
letter_to_numbers(letter: str) numpy.ndarray

Return the pair of numbers that represents the given letter in the polybius square >>> np.array_equal(PolybiusCipher().letter_to_numbers(‘a’), [1,1]) True

>>> np.array_equal(PolybiusCipher().letter_to_numbers('u'), [4,5])
True
numbers_to_letter(index1: int, index2: int) str

Return the letter corresponding to the position [index1, index2] in the polybius square

>>> PolybiusCipher().numbers_to_letter(4, 5) == "u"
True
>>> PolybiusCipher().numbers_to_letter(1, 1) == "a"
True
SQUARE
ciphers.polybius.SQUARE = [['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'k'], ['l', 'm', 'n', 'o', 'p'], ['q', 'r',...