key = 'abcdefghijklmnopqrstuvwxyz'credit by kak thomas thanks..
def encrypt(n, plaintext):
"""Encrypt the string and return the ciphertext"""
result = ''
for l in plaintext.lower():
try:
i = (key.index(l) + n) % 26
result += key[i]
except ValueError:
result += l
return result.lower()
def decrypt(n, ciphertext):
"""Decrypt the string and return the plaintext"""
result = ''
for l in ciphertext:
try:
i = (key.index(l) - n) % 26
result += key[i]
except ValueError:
result += l
return result
for i in range(27):
print i, decrypt (i,"frynzng. naqn oryhz orehaghat ")
print encrypt(3,"wiki")
Jumat, 28 Desember 2018
Caesar Chiper Bruteforce python
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar