Kevin pinged me earlier today with an interesting issue. He had a Base64 representation of data. Base64 is usually used to create a string representation of binary data. But did you know that you can also Base64 encode string data?
|Published (Last):||15 September 2015|
|PDF File Size:||3.26 Mb|
|ePub File Size:||16.86 Mb|
|Price:||Free* [*Free Regsitration Required]|
Kevin pinged me earlier today with an interesting issue. He had a Base64 representation of data. Base64 is usually used to create a string representation of binary data. But did you know that you can also Base64 encode string data? In his case it was being used in some PHP code to encode layout for a blog theme.
He needed to get to the original code but wasn't sure how to do that in ColdFusion. Here is what I came up with. First, start off with your Base64 string. Note - in the code template below I'm going to add a few spaces just to make it wrap better. ColdFusion provides a toBase64 function but no "from"Base There is a toString function, but since Base64 is already a string, running toString on it doesn't do anything.
However, we can convert this into binary data using toBinary:. But how do we view it? If you try to output f you will get an error. But now is the time where toString helps out:.
Wow that PHP code looks awesome! Anyway - I hope this helps others. This is the first I've seen of Base64 versions of strings. It seems to be used as a way to obfuscate the code. I've also heard that apparently this has been used to hack Wordpress themes as well.
Converting A Base64 Value Back Into A String Using ColdFusion
Converts a string to a binary object. Used to convert binary data that has been encoded into string format back into binary data. A string that specifies the algorithm used to encode the original binary data into a string; must be one of the following:. Use this function to convert a binary-encoded string representation of binary data back to a binary object for use in your application.
Working with Base64 representations of strings in ColdFusion
This was sort of based on an Ask Ben inquiry, so I will include it in this section, but it's not entirely accurate. Someone had asked me about passing a file to a web service and I had suggested that one of the ways to do this was to pass it using a Base64 encoding of the binary data. There are two players in this game. One entity is the file that reads the file data, encodes it, and submits it to the web service.