Skip to content

Added A1Z26 Cipher #1914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 29, 2020
Prev Previous commit
Next Next commit
Added Doctests
  • Loading branch information
LethargicLeprechaun committed Apr 29, 2020
commit d3bddb6f1cf64284df6aed69f2b1487d9af9da7f
8 changes: 8 additions & 0 deletions ciphers/a1z26.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
def encode(plain : str) -> list:
"""
>>> encode("MyName")
Encoded: [13, 25, 14, 1, 13, 5]
"""
result = []
for elem in plain:
result.append(ord(elem) - 96)
return result

def decode(encoded : list) -> str:
"""
>>> decode([13, 25, 14, 1, 13, 5])
Decoded: myname
"""
result = ""
for elem in encoded:
result += chr(elem + 96)
Expand Down