Created
September 13, 2019 17:30
-
-
Save bandrel/3b2da60ddb85c31d63dbc0e531905409 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
import argparse | |
import binascii | |
parser = argparse.ArgumentParser(description='Encoding and Decoding F5 URL Rewrites') | |
parser.add_argument('mode', type=str, help='text to encode or decode') | |
parser.add_argument('input_text', type=str, help='text to encode or decode') | |
parser.add_argument('--host', type=str, help='original F5 baseurl') | |
def encode(input_word): | |
return(binascii.hexlify(input_word.encode('iso-8859-9'))) | |
def decode(input_word): | |
return(bytes.fromhex(input_word)) | |
args = parser.parse_args() | |
if args.mode.lower() == 'encode': | |
if args.host: | |
print('https://{0}/f5-w-{1}$$/'.format(args.host, encode(args.input_text).decode("utf-8"))) | |
else: | |
print('/f5-w-{0}$$/'.format(encode(args.input_text).decode("utf-8"))) | |
if args.mode.lower() == 'decode': | |
print(''.format(decode(args.input_text))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment