ciphers.bifid

The Bifid Cipher uses a Polybius Square to encipher a message in a way that makes it fairly difficult to decipher without knowing the secret.

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

Attributes

SQUARE

Classes

BifidCipher

Module Contents

class ciphers.bifid.BifidCipher
decode(message: str) str

Return the decoded version of message according to the polybius cipher

>>> BifidCipher().decode('qtltbdxrxlk') == 'testmessage'
True
encode(message: str) str

Return the encoded version of message according to the polybius cipher

>>> BifidCipher().encode('testmessage') == 'qtltbdxrxlk'
True
>>> BifidCipher().encode('Test Message') == 'qtltbdxrxlk'
True
>>> BifidCipher().encode('test j') == BifidCipher().encode('test i')
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(BifidCipher().letter_to_numbers('a'), [1,1])
True
>>> np.array_equal(BifidCipher().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

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