Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import string
- def substCipher(text, alph, alphabet):
- res = list(text)
- alphTemp = list(alph)
- for i in range(0, len(text)):
- res[i] = alphTemp[alphabet.index(res[i])]
- return res
- def substDecipher(text, alph, alphabet):
- tmp = list(alphabet)
- res = list(text)
- alphTemp = list(alph)
- for i in range(0, len(text)):
- res[i] = tmp[alphTemp.index(res[i])]
- return res
- alphabet = "abcdefghijklmnopqrstuvwxyz"
- print("Enter your message: ")
- mes = str(input())
- #print("Enter new alphabet: ")
- #alphabetNew = str(input())
- alphabetNew = "zaqwsxcderfvbgtyhnmjuiklop"
- mes = mes.lower()
- mes = mes.replace(' ', '')
- result = ''.join(substCipher(mes, alphabetNew, alphabet))
- print(result)
- resultDecipher = ''.join(substDecipher(result, alphabetNew, alphabet))
- print(resultDecipher)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement