Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import socket
- import sys
- import random
- import time
- print("""
- 88 88
- 88 88
- 88 88 88 88 89 88 88 8888888
- 8888888 88 88 88889 88 88 88
- 88 88 88 88 88 88 88 8888888
- 88 88 88 88 88 88 88 88
- 88 88 8888888 88 8888888 8888888
- +--------------------------+
- | Coded By Godlik |
- | |
- | "Version: 0.1" |
- +--------------------------+
- Inserisci il numero dell'operazione che vuoi fare:
- > 1 --------->
- > 2 --------->
- > 3 ---------> Opzioni Cifrario di Cesare
- """)
- scelta1 = input("> ")
- if scelta1 == "1":
- if scelta1 == "3":
- key = 0
- MAX_KEY = 26
- def getMode():
- while True:
- print("""
- ------> Opzioni Cifrario di Cesare
- ------> Opzioni Cifrario di Cesare
- ------> Opzioni Cifrario di Cesare
- > 1 Cifra
- > 2 Decifra
- > 3 Bruteforce*
- * La funzione Bruteforce serve per decifrare un messaggio
- di cui non di sa la chiave di cifratura.
- """)
- mode =input("> ")
- if mode in "1 2 3".split():
- return mode
- else:
- print("---- ERRORE ----")
- def getMessage():
- print("Inserire il Messaggio > ")
- return input()
- def getKey():
- while True:
- key = int(input(Inserire la Chiave > ))
- if(key >= 1 and key <= MAX_KEY):
- return key
- def getTranslateMessage(mode, message, key):
- translate = ''
- if mode[0] == '2':
- key = -key
- for symbol in message:
- if symbol.isalpha():
- num = ord(symbol)
- num += key
- if symbil.isupper():
- if num > ord('z'):
- num -= 26
- elif num < ord('A'):
- num += 26
- elif symbol.islower():
- if num > ord('z'):
- num -= 26
- elif num < ord('a'):
- num += 26
- translate += chr(num)
- else:
- translate += symbol
- return translate
- mode = getMode()
- message = getMessage()
- if mode[0] != '3':
- ket = getKey()
- if mode[0] != '3':
- print("""
- -----> Messaggio finale:""")
- print(getTranslateMessage(mode, message, key))
- else:
- for ket in range(1, MAX_KEY+1):
- print(key, getTranslateMessage('2' message, key))
- fine = input("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement