Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Atbash Cipher by mikaeldovbnia
def atbash(plaintext):
if plaintext == '':
return ''
f = str(plaintext)
a = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
b = 'zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA'
d = ''
for i in f:
if a.count(i) == 0:
d += i
else:
d += b[a.index(i)]
if plaintext[0] == plaintext[0].upper():
return d
return d
if __name__ == "__main__":
print("Example:\nplaintext: testing")
print(atbash("testing"))
# These "asserts" are used for self-checking and not for an auto-testing
assert atbash("testing") == "gvhgrmt"
assert atbash("attack at dawn") == "zggzxp zg wzdm"
assert atbash("Hello, world!") == "Svool, dliow!"
print("Coding complete? Click 'Check' to earn cool rewards!")
March 18, 2022
Comments: