Created
January 3, 2020 12:21
-
-
Save ymt117/50d03af0cf5e622ca5730064ce0cb840 to your computer and use it in GitHub Desktop.
rot13のプログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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