I'm trying to get the correct base64 string by encoding a hex string. It works when I use converter websited but my App does not.
NSData* sentData = [combinedHexMessage dataUsingEncoding : NSUTF8StringEncoding];
NSLog (@"%@",sentData);
NSData* sentDataBase64 = [sentData base64EncodedDataWithOptions:0];
NSLog(@"%@",[NSString stringWithUTF8String:[sentDataBase64 bytes]]);
This is my code. combinedHexMessage
looks like this in NSLog
:
ffd8ffe000104a46494600010101006000600000ffdb004300020101020101020 ...
sentData
:
66666438 66666530 30303130 34613436 34393436 30303031 30313031 ...
sentDataBase64
:
ZmZkOGZmZTAwMDEwNGE0NjQ5NDYwMDAxMDEwMTAwNjAwMDYwMDAwMGZmZGIwMDQzM ...
But it should look like:
/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFB ...
Because this is the string I get after I paste my hex
string there:
http://tomeko.net/online_tools/hex_to_base64.php?lang=en
What am I doing wrong?