I have to encode an array of bytes to a base64 string (and decode this string) on an old Delphi 2007.How could I do?
I've tried synapse (As suggested here Binary to Base64 (Delphi)).
Since two weeks, I'm trying and reading to solve this problem, but everything I tried didn't worked :-(
I'm using python 2.7.
I do have, as far as I understand, a base64-string from the format:
I want to convert it to a hex-string. Which should result in
I tried it with the following code:
def itemid_to_entryid(itemid): decoded_val = base64.b64decode(itemid) decoded_val = ''.join( ["%02X" % ord(x) for x in decoded_val ] ).strip() decoded_val = decoded_val.upper() return decoded_valitemid = 'AAMkADk0ZjU4ODc1LTY1MzAtNDdhZS04NGU5LTAwYjE2Mzg5NDA1ZABGAAAAAAAZS9Y2rt6uTJgnyUZSiNf0BwC6iam6EuExS4FgbbOF87exAAAAdGVuAAC6iam6EuExS4FgbbOF87exAAAxj5dhAAA='entryid = itemid_to_entryid(itemid)print(entryid)
which always returns me the following:
and I really don't get, what I'm doing wrong and really would appreciate any help in understanding what I'm doing wrong.
I have an Base 64 encoded string:"MTg2MTYyOTAuMTQ5MTg1NzAxMy4a1x1biIm69KFEf6yYRztKIW745NNj+qzzDAQoEOiBYw=="
When I try to Base 64 decode this in Android it is giving some garbage characters.
Output : 18616290.1491857013.�[����D��G;J!n���c��(�c
Expected : 18616290.1491857013.[DG;J!nc(c
The code I am using is :
String val =new String(Base64.decode(encodedString,Base64.DEFAULT));
There are some garbage "?" characters getting introduced. How do I get rid of them ?
I have a method that returns an
unsigned char * array and I am trying to encode this as base64 and decode it later. So what I am doing is as follows:
unsigned char * val = myMethod();char * encodedMsg = reinterpret_cast<char *>(val);std::cout << "Returned message: " << val << std::endl;QByteArray raw = QByteArray(encodedMsg).toBase64(QByteArray::Base64Encoding | QByteArray::OmitTrailingEquals);
The output from the method is
\u0001z\ri!i, and the encoded value is
Now, I decode it as follows:
QByteArray decoded = QByteArray::fromBase64(raw, QByteArray::Base64Encoding | QByteArray::OmitTrailingEquals);qDebug() << decoded;
Now this returns
\\u0001z\\ri!i,. Notice that the slashes have been escaped.
I know I can replace this as a post processing step but is there a way to avoid this. Perhaps I am using the encoding/decoding incorrectly?