I am using Gmail API in order to read the emails from Gmail account. I am taking the body and I am replacing some chars which are needed as I read in the forums:
String codedBody = body.Replace("-", "+"); codedBody = codedBody.Replace("_", "/");
Problem is that when I try to convert it
byte data = Convert.FromBase64String(codedBody);
there is an exception which is firing with some emails:
System.FormatException: 'The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.'
The string which is coming from the request is:
Any ideas what is causing this problem?
I Know base64 encoding is unique, but while decoding due to (padding or hex stuff) it can make two differently encoded strings to result into a same decoded string.
EDIT: one case
QzNWwQ== will decode to = C3V
QzNWwc== will also decode to = C3V
so how to make every decoding unique?
I am facing a major issue in encoding/decoding a base 64 image.
My purpose is to save a canvas image as base64 decoded string that can later be base64 encoded in php.
var string= canvas.toDataURL("image/jpeg");var abc = window.atob(string.split(","));var blob = "HEADERS"+abc;
blob is the file.
$Data = blob File$img = substr($Data, $start, $end);$img = base64_encode($img);
I start when I find chr(0xFF) . chr(0xD8) in the blob file and end when I find chr(0xFF) . chr(0xD9)
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)).