Skip to content

Instantly share code, notes, and snippets.

@bandrel
Created September 13, 2019 17:30
Show Gist options
  • Save bandrel/3b2da60ddb85c31d63dbc0e531905409 to your computer and use it in GitHub Desktop.
Save bandrel/3b2da60ddb85c31d63dbc0e531905409 to your computer and use it in GitHub Desktop.
#!/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