utage: encryption/decryption tool
This commit is contained in:
parent
9a8bb4f89e
commit
71e8c9d257
4 changed files with 242 additions and 0 deletions
35
divatool.py
35
divatool.py
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
import argparse
|
||||
import sys
|
||||
from os import path
|
||||
|
||||
from adx import adx
|
||||
from utage import utage
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Unpack and process XDU data")
|
||||
|
|
@ -21,11 +24,43 @@ def main():
|
|||
help="Input directory containing ADX files",
|
||||
type=str)
|
||||
|
||||
# utage subcommand
|
||||
parser_utage = subparsers.add_parser("utage", help="UTAGE stuff")
|
||||
parser_utage_subparsers = parser_utage.add_subparsers(metavar="<command>", title="subcommand", dest="subcommand")
|
||||
# utage crypt
|
||||
parser_utage_crypt = parser_utage_subparsers.add_parser("crypt", help="Encrypt/decrypt utage tsv files")
|
||||
parser_utage_crypt.add_argument("--encrypt", "-e",
|
||||
help="Encrypt (default: Decrypt)",
|
||||
dest="encrypt", action="store_true", default=False)
|
||||
parser_utage_crypt.add_argument("--no-compression", "-n",
|
||||
help="Do not compress/decompress. Only applies to tsv, png will never be compressed",
|
||||
dest="ncomp", action="store_true", default=False)
|
||||
parser_utage_crypt.add_argument("--key", "-k",
|
||||
help="Encryption key (Default: SampleSecretKey)",
|
||||
dest="key", type=str, default="SampleSecretKey")
|
||||
parser_utage_crypt.add_argument("--hex", "-x",
|
||||
help="KEY is hexadecimal (Default: False)",
|
||||
dest="hex", action="store_true", default=False)
|
||||
parser_utage_crypt.add_argument("TARGET",
|
||||
help="Input", type=str)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.command == "adx":
|
||||
if args.subcommand == "loop":
|
||||
adx.extract_loop_data_from_dir(args.ADX_DIR, args.JSON_OUT)
|
||||
elif args.command == "utage":
|
||||
if args.subcommand == "crypt":
|
||||
if not args.hex:
|
||||
key = bytearray(args.key, "utf-8")
|
||||
else:
|
||||
key = bytearray.fromhex(args.key)
|
||||
if path.isfile(args.TARGET):
|
||||
utage.crypt_file(args.TARGET, key, args.encrypt, args.ncomp)
|
||||
elif path.isdir(args.TARGET):
|
||||
utage.crypt_dir(args.TARGET, key, args.encrypt, args.ncomp)
|
||||
else:
|
||||
raise FileNotFoundError("Could not find {}".format(args.TARGET))
|
||||
|
||||
return 0
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue