Skip to content

Instantly share code, notes, and snippets.

@ymt117
Created January 3, 2020 12:21
Show Gist options
  • Save ymt117/50d03af0cf5e622ca5730064ce0cb840 to your computer and use it in GitHub Desktop.
Save ymt117/50d03af0cf5e622ca5730064ce0cb840 to your computer and use it in GitHub Desktop.
rot13のプログラム
# Reference:
# https://blog.finxter.com/how-to-use-rot13-in-python/
import argparse
ap = argparse.ArgumentParser()
ap.add_argument('arg1', help='plain text')
ap.add_argument('-n', help='number of rotation')
args = ap.parse_args()
cleartxt = args.arg1
abc = "abcdefghijklmnopqrstuvwxyz"
if args.n is None:
rot_n = 13
else:
rot_n = int(args.n)
secret = "".join([abc[(abc.find(c)+rot_n)%26] for c in cleartxt])
print(secret)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment