-
Notifications
You must be signed in to change notification settings - Fork 0
/
cryptobin.py
executable file
·83 lines (72 loc) · 2.65 KB
/
cryptobin.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python
"Cryptobin CLI."
import argparse
import string
from analysis import chars
from analysis import frequency
from ciphers import bifid
from ciphers import playfair
from ciphers import rot
from ciphers import submap
from ciphers import vigenere
from encoding import encoding
from encoding import morse
from encoding import roman
from encoding import tonal
from language import anagram
from language import dictionary
from language import words
from maths import integer
from lib import io
parser = argparse.ArgumentParser(description="cryptobin cli tool.")
subparsers = parser.add_subparsers(metavar="SUBCOMMAND")
# Common arguments.
parser.add_argument("file",
metavar="FILE",
nargs="?",
help="the input to be processed")
parser.add_argument("-l",
"--language",
type=str,
default=dictionary.DEFAULT_LANG,
help="the language being analyzed, in ISO 639-1 (default: "
"en)")
# Subcommands.
anagram.define_arguments(
subparsers.add_parser("anagram", help="anagram utilities"))
bifid.define_arguments(
subparsers.add_parser("bifid", help="bifid cipher utilities"))
chars.define_arguments(
subparsers.add_parser("count", help="character counting"))
encoding.define_arguments(
subparsers.add_parser("enc", help="character encoding transformations"))
frequency.define_arguments(
subparsers.add_parser("fa", help="frequency analysis"))
integer.define_arguments(
subparsers.add_parser("int", help="integer sequence analysis"))
morse.define_arguments(
subparsers.add_parser("morse", help="morse encoding utilities"))
playfair.define_arguments(
subparsers.add_parser("playfair", help="playfair cipher utilities"))
roman.define_arguments(
subparsers.add_parser("roman", help="roman numeral encoding utilities"))
rot.define_arguments(
subparsers.add_parser("rot", help="text rotation (e.g. ROT13) utilities"))
submap.define_arguments(
subparsers.add_parser("submap", help="substitution cipher utilities"))
tonal.define_arguments(
subparsers.add_parser("tonal", help="tonal encoding utilities"))
vigenere.define_arguments(
subparsers.add_parser("vigenere", help="vigenere cipher utilities"))
words.define_arguments(subparsers.add_parser("words", help="word utilities"))
def main():
args, data = io.parse_args(parser)
if hasattr(args, "func"):
try:
args.func(data, args)
except ValueError as e:
parser.error(e)
else:
parser.error("subcommand not recognized, use -h to list subcommands")
if __name__ == "__main__":
main()