Encrypting URL parameters in Coldfusion.
So on looking around the internet for a suitable solution to passing encrypted strings sensibly through URL variables. I found all the usual suspects from encrypting with base64 conversion to straight encrypting. These all had the issue of mangling the string when passed through a URL, either CFWheels would lowercase everything (hence wrecking Base64 encoding), or in the case of simply encoding and even using URLEncode several characters would get trashed completely.
I found that the best solution was to provide the Encrypt() function with it’s additional params: algorithm and encoding. See http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_c-d_40.html#1103962 for details. I picked the Hex encoding for a sensible character set (on retrospect UUEncode would work as well if you take in account the extra characters that will need to be URL encoded). So my encode call looked as follows:
encrypt(toEncodeString, algorithmkey, "CFMX_COMPAT", "HEX")
And the Decode would go as follows:
decrypt(urlStringToDecode, algorithmkey, "CFMX_COMPAT", "HEX")