I'am using EncodeString in Delphi 7 to encode strings which load from a source textfile. In the source textfile, every line is one record. Now, I want to use the function EncodeString which is Base64 function to encode every line string and write to a new target textfile. My purpose is one line strings in source textfile should encode to one line encryption strings in target textfile. But every line encode to 3 lines encryption strings. There are several line-breaks made to 3 lines. How can I delete the line feed?
Code:
procedure TForm1.Button1Click(Sender: TObject);
var
i,sum:integer;
begin
memoSource.Lines.LoadFromFile('source.txt');
sum:=memoSource.Lines.Count;
assignFile(targetFile,'target.txt');
rewrite(targetFile);
memoTarget.Clear;
for i:=0 to sum-1 do
begin
memoTarget.Lines.Append(EncodeString(memoSource.Lines.Strings[i]));
Writeln(targetFile,EncodeString(memoSource.Lines.Strings[i]));
//Write(targetFile,EncodeString(memoSource.Lines.Strings[i])); //use write but line-feed still in the strings
end;
end;
this is source text content:
line 1: this is a soure text to test , every line is one record. this is a soure text to test , every line is one record. this is a soure text to test , every line is one record.
line 2: this is a soure text to test , every line is one record. this is a soure text to test , every line is one record. this is a soure text to test , every line is one record.
line 3: this is a soure text to test , every line is one record. this is a soure text to test , every line is one record. this is a soure text to test , every line is one record. code here
this is EncodeString text content:
bGluZSAxOiB0aGlzIGlzIGEgc291cmUgdGV4dCB0byB0ZXN0ICwgZXZlcnkgbGluZSBpcyBvbmUg
cmVjb3JkLiB0aGlzIGlzIGEgc291cmUgdGV4dCB0byB0ZXN0ICwgZXZlcnkgbGluZSBpcyBvbmUg
cmVjb3JkLiB0aGlzIGlzIGEgc291cmUgdGV4dCB0byB0ZXN0ICwgZXZlcnkgbGluZSBpcyBvbmUg
cmVjb3JkLg==
bGluZSAyOiB0aGlzIGlzIGEgc291cmUgdGV4dCB0byB0ZXN0ICwgZXZlcnkgbGluZSBpcyBvbmUg
cmVjb3JkLiB0aGlzIGlzIGEgc291cmUgdGV4dCB0byB0ZXN0ICwgZXZlcnkgbGluZSBpcyBvbmUg
cmVjb3JkLiB0aGlzIGlzIGEgc291cmUgdGV4dCB0byB0ZXN0ICwgZXZlcnkgbGluZSBpcyBvbmUg
cmVjb3JkLg==
bGluZSAzOiB0aGlzIGlzIGEgc291cmUgdGV4dCB0byB0ZXN0ICwgZXZlcnkgbGluZSBpcyBvbmUg
cmVjb3JkLiB0aGlzIGlzIGEgc291cmUgdGV4dCB0byB0ZXN0ICwgZXZlcnkgbGluZS
I need a line-break in every target textfile line end so I can distinguish every line.
thanks a lot!