forked from aokad/ecsub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecsub_tools
43 lines (32 loc) · 1.16 KB
/
ecsub_tools
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 14 11:53:04 2018
@author: Okada
"""
import sys
import argparse
import ecsub.encrypt as encrypt
from ecsub import __version__
def main():
prog = "ecsub_tools"
parser = argparse.ArgumentParser(prog = prog)
parser.add_argument("--version", action = "version", version = prog + "-" + __version__)
subparsers = parser.add_subparsers()
##########
# encrypt
encrypt_parser = subparsers.add_parser("encrypt", help = "encrypt plain text")
encrypt_parser.add_argument("plain_text", metavar = "PlainText", help = "set your secret text", type = str)
encrypt_parser.set_defaults(func = encrypt.encrypt)
##########
# decrypt
decrypt_parser = subparsers.add_parser("decrypt", help = "decrypt cipher text")
decrypt_parser.add_argument("cipher_text", metavar = "CipherText", help = "cipher text", type = str)
decrypt_parser.set_defaults(func = encrypt.decrypt)
argv = sys.argv[1:]
if len(argv) < 1:
argv = [""]
args = parser.parse_args(argv)
return args.func(args)
if __name__ == "__main__":
print (main())