def test_punc_white_decrypt(self): v = ciphers.vigenere() ciphertext = 'Zincs Ostch!' expected = 'Hello World!' keyword = 'secret' plaintext = v.decrypt(ciphertext, keyword) self.assertEqual(plaintext, expected)
def test_short_decrypt(self): v = ciphers.vigenere() expected = 'apple' ciphertext = 'cdspg' keyword = 'code' plaintext = v.decrypt(ciphertext, keyword) self.assertEqual(plaintext, expected)
def test_wikipedia_decrypt(self): v = ciphers.vigenere() ciphertext = 'LXFOPVEFRNHR' expected = 'ATTACKATDAWN' keyword = 'LEMON' plaintext = v.decrypt(ciphertext, keyword) self.assertEqual(plaintext, expected)
) text = input("Enter the text : ") #s = int(input("Enter the Shift : ")) print("\nCipher text: " + ceaserEncrypt(text, 13) + '\n\n') break elif choose == '2': print( '\n\n***********************Vigenere Cipher***********************\n\n' ) text = input("Enter the text : ") text = text.upper() keyword = input("Enter the keyword : ") keyword = keyword.upper() key = generateKey(text, keyword) cipher_text = vigenere(text, key) print("\nCipher text : " + cipher_text + '\n\n') break elif choose == '3': print( '\n\n***********************Atbash Cipher***********************\n\n' ) message = input('Enter the text : ') print('\nCipher text : ' + (atbash(message.upper())) + '\n\n') break elif choose == '4': print( '\n\n***********************Rail-Fence Cipher***********************\n\n' )
shift = ciphers.shift() print('Shift by 6: {} | {}'.format(plain, shift.encrypt(plain, 6))) key = 'qagydutpohckbjxsmwvrfizeln' plain = "It's the best day ever!" subs = ciphers.substitution() print('Substitution: {} | {}'.format(plain, subs.encrypt(plain, key))) key = 'qagydutpohckbjxsmwvrfizeln' plain = "Thanks for decrypting this" subs = ciphers.substitution() print('Substitution: {} | {}'.format(plain, subs.encrypt(plain, key))) keyword = 'secret' plain = 'I love this cipher!' v = ciphers.vigenere() print('Vigenère: {} | {}'.format(plain, v.encrypt(plain, keyword))) keyword = 'youthcodejam' plain = "I hope I don't run out of time" v = ciphers.vigenere() print('Vigenère: {} | {}'.format(plain, v.encrypt(plain, keyword))) print('***** Challenges *****') plain = 'We the People of the United States, in Order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for the United States of America.' shift = ciphers.shift() print('Shift by -8: {} | {}'.format(plain, shift.encrypt(plain, -8))) plain = 'I pledge allegiance to the Flag of the United States of America, and to the Republic for which it stands, one Nation under God, indivisible, with liberty and justice for all.' keyword = 'ycj' v = ciphers.vigenere()