def test_encryption_passSentence1(self): M = "I am Sir Oracle, And when I ope my lips, let no dog bark!" SimpleEncrypter.setMessage(M) SimpleEncrypter.setCryptography({' ': '.'}, distance=0) thread = SimpleEncrypter(0, 1) thread.run() self.assertTrue(SimpleEncrypter.getMessage( ) == "I.am.Sir.Oracle,.And.when.I.ope.my.lips,.let.no.dog.bark!")
def test_encryption_passSentence(self): M = "I am Sir Oracle, And when I ope my lips, let no dog bark!" SimpleEncrypter.setMessage(M) SimpleEncrypter.setCryptography(self.__dict_upperLetters, distance=0) thread = SimpleEncrypter(0, 1) thread.run() self.assertTrue(SimpleEncrypter.getMessage( ) == "P am Uir Dracle, Vnd when P ope my lips, let no dog bark!")
def test_encryption_passSentence2(self): M = "I am Sir Oracle, And when I ope my lips, let no dog bark!" SimpleEncrypter.setMessage(M) SimpleEncrypter.setCryptography({' ': '_'}, distance=1) thread = SimpleEncrypter(0, 1) thread.run() self.assertTrue(SimpleEncrypter.getMessage( ) == 'J_bn_Tjs_Psbdmf-_Boe_xifo_J_pqf_nz_mjqt-_mfu_op_eph_cbsl"')
def test_encryption_passfile(self): plain = open("scripts/testfile.text", "r") cipher = open("scripts/testfile_encrypted.text", "r") with plain, cipher: message = plain.read() SimpleEncrypter.setMessage(message) SimpleEncrypter.setCryptography(self.__dict_upperLetters, distance=10) thread = SimpleEncrypter(0, 1) thread.run() self.assertTrue(SimpleEncrypter.getMessage() == cipher.read())
def getEncryptedMessage(self): threads = [] SimpleEncrypter.setCryptography(self.__secretDictionary) SimpleEncrypter.setMessage(self.__message) for i in range(self.__threadcount): t = SimpleEncrypter(i, self.__threadcount) threads.append(t) t.start() for j in range(self.__threadcount): threads[j].join() encryptedM = SimpleEncrypter.getMessage() return encryptedM
def test_message_empty(self): SimpleEncrypter.setMessage("") SimpleEncrypter.setCryptography(self.__dict_upperLetters) self.assertTrue(len(SimpleEncrypter.getMessage()) == 0)
def test_message_dict(self): SimpleEncrypter.setMessage({'A':'B','C':'D', 'E':'F'}) SimpleEncrypter.setCryptography(self.__dict_upperLetters) self.assertTrue(SimpleEncrypter.getMessage() == 'ACE')
def test_message_dict_run(self): SimpleEncrypter.setMessage({'A': 'B', 'C': 'D', 'E': 'F'}) SimpleEncrypter.setCryptography(self.__dict_upperLetters) thread = SimpleEncrypter(0, 1) with self.assertRaises(TypeError): thread.run()
def tearDown(self): # now we have to cleanup! SimpleEncrypter.setCryptography({},distance=0) SimpleEncrypter.setMessage("")
def test_init_parameters_pass(self): thread = SimpleEncrypter(firstIndex=0, offset=3) thread.setMessage("ABCDEF") thread.setCryptography(self.__dict_upperLetters) thread.run() self.assertTrue(thread.getMessage() == "VBCBEF")
def test_message_tuple2(self): SimpleEncrypter.setMessage(('A', 'B', 'C', 'D', 'E')) SimpleEncrypter.setCryptography(self.__dict_upperLetters) self.assertTrue(SimpleEncrypter.getMessage() == 'ABCDE')
def test_message_tuple_run(self): SimpleEncrypter.setMessage(('A', 'B', 'C', 'D', 'E')) SimpleEncrypter.setCryptography(self.__dict_upperLetters) thread = SimpleEncrypter(0, 1) thread.run() self.assertTrue(SimpleEncrypter.getMessage() == "VJZBG")
def test_message_length(self): message = "hello world and everyone else" SimpleEncrypter.setMessage(message) SimpleEncrypter.setCryptography("") self.assertTrue(len(SimpleEncrypter.getMessage()) == len(message))
def test_message_list1(self): SimpleEncrypter.setMessage(['A', 'B', 'C', 'D']) SimpleEncrypter.setCryptography(self.__dict_upperLetters) self.assertTrue(SimpleEncrypter.getMessage() == 'ABCD')
def test_encryption_fails(self): thread = SimpleEncrypter(firstIndex=0, offset=1) SimpleEncrypter.setMessage("get rekt") SimpleEncrypter.setCryptography(self.__dict_upperLetters) thread.run() self.assertFalse(SimpleEncrypter.getMessage() == "FGC QGIC")
def test_encryption_pass1(self): thread = SimpleEncrypter(1, 2) SimpleEncrypter.setMessage("hello") SimpleEncrypter.setCryptography(self.__dict_upperLetters, distance=1) thread.run() self.assertTrue(SimpleEncrypter.getMessage() == "hflmo")
def test_encryption_pass2(self): thread = SimpleEncrypter(1, 2) SimpleEncrypter.setMessage("HELLO") SimpleEncrypter.setCryptography(self.__dict_upperLetters, distance=0) thread.run() self.assertTrue(SimpleEncrypter.getMessage() == "HGLTO")
def test_encryption_passDistance(self): SimpleEncrypter.setMessage("hello") SimpleEncrypter.setCryptography(self.__dict_upperLetters, distance=10) thread = SimpleEncrypter(0, 1) thread.run() self.assertTrue(SimpleEncrypter.getMessage() == "rovvy")
def test_encryption_passLongDistance(self): SimpleEncrypter.setMessage('xyz !"#') SimpleEncrypter.setCryptography(self.__dict_upperLetters, distance=100) thread = SimpleEncrypter(0, 1) thread.run() self.assertTrue(SimpleEncrypter.getMessage() == ":;< [\]")