def test_substitution_encrypt():
    plaintext = ciphertexts['plaintext']
    desired_ciphertext = ciphertexts['Substitution']

    cipher = Substitution(30)
    encrypted_text = cipher.encrypt(plaintext)

    assert encrypted_text == desired_ciphertext
Example #2
0
from utils import get_args, get_text_data
from substitution import Substitution
from vigenere import Vigenere
from caesar import Caesar

args = get_args()
file_data = get_text_data(args['FILENAME'])
text = file_data

if args['CIPHER'] == 'SUBSTITUTION':
    substitution = Substitution()

    if args['SHOULD_ENCRYPT']:
        key = args['ENCRYPTION_KEY']
        encrypted = substitution.encrypt(text, key)
        print(encrypted)

    elif args['SHOULD_DECRYPT']:
        decrypted = substitution.decrypt(text)
        print(decrypted)

elif args['CIPHER'] == 'VIGENERE':
    vigenere = Vigenere()

    if args['SHOULD_ENCRYPT']:
        key = args['ENCRYPTION_KEY']
        encrypted = vigenere.encrypt(text, key)
        print(encrypted)

    elif args['SHOULD_DECRYPT']: