Python script for Apache RewriteMap

It turned out that I didn’t need this after all, but thought I’d post it here anyway …

The use case was to base64-encode a URL so that it could be passed as a query parameter to a login page.  The login routes through a third page and returns to the logn page, which redirects the client back to the original URL which was base64-encoded.  Without the encoding, the third page could mangle the original URL.

#!/usr/bin/python

import binascii
import sys

while sys.stdin:
    print binascii.b2a_base64(sys.stdin.readline().rstrip()) ,
    sys.stdout.flush()
Advertisements

, , ,

  1. #1 by Cogsy on December 19, 2009 - 7:07 pm

    Thanks man. Just the hint I needed to get the apache IO working.