コード例 #1
0
ファイル: main.py プロジェクト: AdamLounsbury/PyCiphers
def main():
    """Menu display of available operations"""

    print '\nWelcome! Please input a numbered option below\n'
    print '1) Single encryption'
    print '2) Multiple encryption (with random key generation)'
    print '3) Single decryption'
    print '4) Brute-force code breaking'
    print '5) Quit\n'

    main_choice = raw_input('> ')

    if main_choice == '1':
        return single_encryption_decryption('e')
    elif main_choice == '2':
        cipher_text = multiple_encryption()
        return clipboard(cipher_text)
    elif main_choice == '3':
        return single_encryption_decryption('d')
    elif main_choice == '4':
        return code_break()
    elif main_choice == '5' or main_choice.startswith('q'):
        sys.exit()
    else:
        print 'Invalid choice'
        return main()
コード例 #2
0
def transposition(text='', option='', key=''):
    """Instantiate a CipherFuncs class for the Transposition cipher, obtaining all required parameters from the user
    based off of what arguments were initially provided and how this method was called.
    """

    transposition_cipher = CipherFuncs(text, option, key)
    text, option, key = transposition_cipher.call_source()

    cipher_text = encrypt_decrypt(text, option, key)
    return clipboard(cipher_text)
コード例 #3
0
ファイル: affine.py プロジェクト: AdamLounsbury/PyCiphers
def affine(text='', option='', key=''):
    """Instantiate a CipherFuncs class for the Affine cipher, obtaining all required parameters from the user
    based off of what arguments were initially provided and how this method was called.
    """

    affine_cipher = CipherFuncs(text, option, key)
    text, option, key = affine_cipher.call_source()

    key_a, key_b = compute_keys(key)

    cipher_text = encrypt_decrypt(text, option, key_a, key_b)
    return clipboard(cipher_text)