Skip to content

Instantly share code, notes, and snippets.

@wise-bit
Created August 21, 2023 05:48
Show Gist options
  • Select an option

  • Save wise-bit/8f4a8cc128207777c28a9de80f035503 to your computer and use it in GitHub Desktop.

Select an option

Save wise-bit/8f4a8cc128207777c28a9de80f035503 to your computer and use it in GitHub Desktop.
Vignere encode and decode
import sys
m = sys.argv[1]
s = sys.argv[2]
key = "wordle"
if m == "e":
print("".join([ chr(((ord(x) - 97) + (ord(key[i % 6]) - 97)) % 26 + 97) for i, x in enumerate(s)]))
elif m == "d":
print("".join([ chr(((ord(x) - 97) - (ord(key[i % 6]) - 97)) % 26 + 97) for i, x in enumerate(s)]))
else:
print("only supports `e` and `d`")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment