Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TNetEncoding.Base64.Encode contains CR LF

Tags:

delphi

Is this behavio(u)r intended?

...
uses
 System.NetEncoding;

...

var
  s: String;
begin
  s := TNetEncoding.Base64.Encode('asjjdhgfaoösjkdhföaksjdfhöasjdfhasdkjasdhfköajsjhdfajssssd');
end;

s contains a CR LF:

YXNqamRoZ2Zhb8O2c2prZGhmw7Zha3NqZGZow7Zhc2pkZmhhc2RramFzZGhma8O2YWpzamhkZmFq '#$D#$A' c3Nzc2Q=

Local variables

The issue with this is that all my http calls return a bad request. The other party does not expect this.

like image 617
complete_stranger Avatar asked Oct 16 '18 13:10

complete_stranger


1 Answers

In that case you can create an instance with the proper parameters yourself:

var
  s: String;
  base64: TBase64Encoding;
begin
  base64 := TBase64Encoding.Create(0); // CharsPerLine = 0 means no line breaks
  try
    s := base64.Encode('asjjdhgfaoösjkdhföaksjdfhöasjdfhasdkjasdhfköajsjhdfajssssd');
  finally
    base64.Free;
  end;
end;
like image 77
Uwe Raabe Avatar answered Nov 10 '22 21:11

Uwe Raabe