Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import sys
# Make sure we have enough arguments to start
if len(sys.argv) != 3:
print("Usage: %s [base] [Sekrit Message]" % sys.argv[0])
exit()
# Print out the letter base, and build the dictionary
dict = {}
for i in range(1,27):
char = chr(i + 96);
print("%d=%s" % (i,char), end = " ") # Print out the key
dict[char] = i # Store the char => number mapping in a dict
print("\n")
base = sys.argv[1]
string = sys.argv[2]
last = base # Starting number
for x in string:
if x == " ": # Skip spaces
continue
y = x.lower()
cur = dict[y]
# How far to jump to the next char
jump = int(cur) - int(last)
if jump < -13: # If it's too big negative we loop around
jump = 26 + jump
if jump > 13: # If it's too big positive then we go negative
jump = jump - 26
print(jump, end=" ")
last = cur
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment