I'm porting functionality from an Objective-C iPhone app to a Javascript iPhone app (Appcelerator Titanium). In Objective-C I have an NSData object that represents this token:
//NSData object printed to the console:
<0cd9f571 b0e66e6d ca410d12 f67a404a 7e64b9b5 d2483fd9 63a9267b 1c7609e2>
It's not a string, it's an NSData object -- an object-oriented wrapper for a byte buffer. When I base64 encode the object, I get this result:
//base64 encoded NSData object
DNn1cbDmbm3KQQ0S9npASn5kubXSSD/ZY6kmexx2CeI=
In my javascript implementation, I have a string representation of the same token. It looks like this:
//string version of the token in my javascript implementation
0cd9f571b0e66e6dca410d12f67a404a7e64b9b5d2483fd963a9267b1c7609e2
When I base64 encode the string object in javascript, I get this result:
//base64 encoded token (string) in javascript
MGNkOWY1NzFiMGU2NmU2ZGNhNDEwZDEyZjY3YTQwNGE3ZTY0YjliNWQyNDgzZmQ5NjNhOTI2N2IxYzc2MDllMg==
The problem is, the web service I'm posting to doesn't want the base64 encoded string, it wants the base64 encoded data! How can I do this in javascript?