def test_encrypt_without_shuffle(self):
     expected_cipher_text = ReaderIO.reader(
         os.path.join(self.base_path, "ShiftCipher-LLF-k25-sh0-s0.txt"),
         "text")
     self.ShiftCipher.config(key=25, shuffle=False, seed=0)
     self.assertEqual(expected_cipher_text,
                      self.ShiftCipher.encrypt(self.plain_text))
Example #2
0
 def setUp(self) -> None:
     # setup path
     classical_path = os.path.abspath(os.path.dirname(__file__))
     test_path = os.path.abspath(os.path.dirname(classical_path))
     self.base_path = os.path.join(test_path, "asset", "texts")
     # create a cipher agent
     self.agent = AffineCipher()
     self.plain_text = ReaderIO.read(
         os.path.join(self.base_path, "Long License File.txt"), "text")
     self.k125_sh0_s0 = ReaderIO.read(
         os.path.join(self.base_path, "AffineCipher-LLF-k125-sh0-s0.txt"),
         "text")
     self.k173_sh1_s0 = ReaderIO.read(
         os.path.join(self.base_path, "AffineCipher-LLF-k173-sh1-s0.txt"),
         "text")
     self.custom_alphabet = ReaderIO.read(
         os.path.join(
             self.base_path,
             "AffineCipher-LLF-alphabet-ascii-lowercase-k396-sh0-s0.txt",
         ),
         "text",
     )
Example #3
0
 def setUp(self) -> None:
     # setup path
     classical_path = os.path.abspath(os.path.dirname(__file__))
     test_path = os.path.abspath(os.path.dirname(classical_path))
     self.base_path = os.path.join(test_path, "asset", "texts")
     # create a cipher agent
     self.agent = MixalphCipher()
     self.plain_text = ReaderIO.read(
         os.path.join(self.base_path, "Long License File.txt"), "text")
     self.sh0_s0 = ReaderIO.read(
         os.path.join(self.base_path, "MixalphCipher-LLF-sh0-s0.txt"),
         "text")
     self.sh1_s0 = ReaderIO.read(
         os.path.join(self.base_path, "MixalphCipher-LLF-sh1-s0.txt"),
         "text")
     self.custom_sort_key = ReaderIO.read(
         os.path.join(
             self.base_path,
             "MixalphCipher-LLF-sortkey-plmnkoijbhuygvcftrdxzsewaq-sh0-s0.txt",
         ),
         "text",
     )
Example #4
0
    def test_terminal_application(self):
        # mock up terminal arguments
        args = [
            "--file",
            "{}".format(os.path.join(self.base_path, "Long License File.txt")),
            "--output",
            "{}".format(
                os.path.join(self.base_path, "Test Atbash Terminal.txt")),
            "--shuffle",
        ]

        # run main function
        atbash_main(tuple(args))

        # test if it's ok
        result = ReaderIO.read(
            os.path.join(self.base_path, "AtbashCipher-LLF-sh1-s0.txt"),
            "text")
        self.assertEqual(self.sh1_s0, result)
Example #5
0
    def test_terminal_application(self):
        # mock up terminal arguments
        args = [
            "--file",
            "{}".format(os.path.join(self.base_path, "Long License File.txt")),
            "--output",
            "{}".format(
                os.path.join(self.base_path, "Test Affine Terminal.txt")),
            "--key",
            "125",
        ]

        # run main function
        affine_main(tuple(args))

        # test if it's ok
        result = ReaderIO.read(
            os.path.join(self.base_path, "AffineCipher-LLF-k125-sh0-s0.txt"),
            "text")
        self.assertEqual(self.k125_sh0_s0, result)
Example #6
0
    def test_terminal_application(self):
        # mock up terminal arguments
        args = [
            "--file",
            "{}".format(os.path.join(self.base_path, "Long License File.txt")),
            "--output",
            "{}".format(
                os.path.join(self.base_path, "Test Mixalph Terminal.txt")),
            "--key",
            "zxcvbnmlkjhgfdsaqwertyuiop",
        ]

        # run main function
        mixalph_main(tuple(args))

        # test if it's ok
        result = ReaderIO.read(
            os.path.join(self.base_path, "MixalphCipher-LLF-sh0-s0.txt"),
            "text")
        self.assertEqual(self.sh0_s0, result)
 def setUp(self) -> None:
     self.ShiftCipher = ShiftCipher()
     self.base_path = os.path.dirname(__file__).replace(
         "mersad/test/classical", "mersad/test/asset/texts")
     self.plain_text = ReaderIO.reader(
         os.path.join(self.base_path, "Long License File.txt"), "text")