def test_distance3_encrypt(self): shift = ciphers.shift() plaintext = 'abc' expected = 'def' ciphertext = shift.encrypt(plaintext, 3) self.assertEqual(ciphertext, expected)
def test_whitespace_decrypt(self): shift = ciphers.shift() ciphertext = 'a b c' expected = 'x y z' plaintext = shift.decrypt(ciphertext, 3) self.assertEqual(plaintext, expected)
def test_whitespace_encrypt(self): shift = ciphers.shift() plaintext = 'x y z' expected = 'a b c' ciphertext = shift.encrypt(plaintext, 3) self.assertEqual(ciphertext, expected)
def test_punctuation_decrypt(self): shift = ciphers.shift() ciphertext = 'a,b,c/' expected = 'x,y,z/' plaintext = shift.decrypt(ciphertext, 3) self.assertEqual(plaintext, expected)
def test_distance3_decrypt(self): shift = ciphers.shift() ciphertext = 'def' expected = 'abc' plaintext = shift.decrypt(ciphertext, 3) self.assertEqual(plaintext, expected)
#!/usr/bin/env python3 import ciphers import string print('***** shift cipher page *****') plain = 'Really important message contained herein' shift = ciphers.shift() print('Shift by -3: {} | {}'.format(plain, shift.encrypt(plain, -3))) plain = 'test message' shift = ciphers.shift() print('Shift by 2: {} | {}'.format(plain, shift.encrypt(plain, 2))) plain = "This message isn't negative" shift = ciphers.shift() print('Shift by -5: {} | {}'.format(plain, shift.encrypt(plain, -5))) plain = "Hello World!" shift = ciphers.shift() print('Shift by 7: {} | {}'.format(plain, shift.encrypt(plain, 7))) plain = "Goodbye World?" shift = ciphers.shift() print('Shift by -4: {} | {}'.format(plain, shift.encrypt(plain, -4))) print('***** substitution cipher page *****') plain = string.ascii_lowercase shift = ciphers.shift() print('Shift by 6: {} | {}'.format(plain, shift.encrypt(plain, 6)))