def runTest(self): #mixed case (long) key secret = ck.Secret() secret.create_secret_key('a') self.assertEqual(len(secret.secret_key), 52, "Expected 52 characters") self.assertTrue('c' in secret.secret_key, "Expected 'c'") self.assertTrue('C' in secret.secret_key, "Expected 'C'")
def runTest(self): #Create an object and populate it with an encryption key s = ck.Secret() s.create_secret_key('l') self.assertEqual(len(s.get_secret_key()), 26, "Expected key length 26 (lower case only)") #Create a text object and use it to store a plain text string text = ck.Text() text.set_plain_text("the quick brown fox jumped over the lazy dog") #Create an encryption object, pass in the string and the key e = es.Encryption() cypher_text = e.encrypt(text.get_plain_text(), s.get_secret_key()) text.set_cypher_text(cypher_text) self.assertEqual(text.get_cypher_text(), cypher_text, "Expected cypher texts to match") self.assertNotEqual(text.get_cypher_text(), text.get_plain_text(), "Expected texts to not match") plain_text = e.decrypt(text.get_cypher_text(), s.get_secret_key()) print plain_text print text.get_plain_text() self.assertEqual(plain_text, text.get_plain_text(), "Expected plain texts to match")
def runTest(self): #upper case key secret = ck.Secret() secret.create_secret_key('u') self.assertEqual(len(secret.secret_key), 26, "Expected 26 characters") self.assertFalse('b' in secret.secret_key, "Expected 'b' to not be in list") self.assertTrue('B' in secret.secret_key, "Expected 'B'")
def runTest(self): #lower case key secret = ck.Secret() secret.create_secret_key('l') self.assertEqual(len(secret.secret_key), 26, "Expected 26 characters") self.assertTrue('a' in secret.secret_key, "Expected 'a'") self.assertFalse('A' in secret.secret_key, "Expected 'A' to not be in list")
def runTest(self): secret = ck.Secret() self.assertEqual(secret.secret_key, [], "Expected empty secret key list") secret.create_secret_key( 'l' ) #Could be any form, just need a value there to test get method self.assertEqual(secret.secret_key, secret.get_secret_key(), "Expected stored key to match fetched key")