예제 #1
0
    def decipher(self, string):
        """Decipher string using ADFGX cipher according to initialised key information.
        Punctuation and whitespace are removed from the input.

        Example::

            plaintext = ADFGX('phqgmeaylnofdxkrcvszwbuti', 'HELLO').decipher(ciphertext)

        :param string: The string to decipher.
        :returns: The enciphered string.
        """
        step2 = ColTrans(self.keyword).decipher(string)
        step1 = PolybiusSquare(self.key, size=5, chars='ADFGX').decipher(step2)
        return step1
예제 #2
0
    def encipher(self, string):
        """Encipher string using ADFGVX cipher according to initialised key information.
        Punctuation and whitespace are removed from the input.

        Example::

            ciphertext = ADFGVX('ph0qg64mea1yl2nofdxkr3cvs5zw7bj9uti8', 'HELLO').encipher(plaintext)

        :param string: The string to encipher.
        :returns: The enciphered string.
        """
        step1 = PolybiusSquare(self.key, size=6, chars='ADFGVX').encipher(string)
        step2 = ColTrans(self.keyword).encipher(step1)
        return step2