Note that there are some explanatory texts on larger screens.

plurals
  1. POTStringList load memorystream? <Delphi>
    primarykey
    data
    text
    <p>edited :</p> <p>My file has several lines. I encrypt the file onto a new file. I want to store each line of decrypted file (=a stream) into StringList. </p> <p>First, I have a file contain :</p> <pre><code>aa bb cc </code></pre> <p>I encrypt the file with this function :</p> <pre><code>procedure EnDecryptFile(pathin, pathout: string; Chave: Word) ; var InMS, OutMS: TMemoryStream; cnt: Integer; C: byte; begin InMS := TMemoryStream.Create; OutMS := TMemoryStream.Create; try InMS.LoadFromFile(pathin) ; InMS.Position := 0; for cnt := 0 to InMS.Size - 1 do begin InMS.Read(C, 1) ; C := (C xor not (ord(chave shr cnt))) ; OutMS.Write(C, 1) ; end; OutMS.SaveToFile(pathout) ; finally InMS.Free; OutMS.Free; end; end; </code></pre> <p>My purpose now is to store original value of each line into StringList. I don't want to store decrypted file into harddisk, so I use stream.</p> <p>This is the function to decrypt the file into stream :</p> <pre><code>procedure DecryptFile(pathin: string; buff: TMemoryStream; Chave: Word); var InMS: TMemoryStream; cnt: Integer; C: byte; begin InMS := TMemoryStream.Create; try InMS.LoadFromFile(pathin); InMS.Position := 0; for cnt := 0 to InMS.Size - 1 do begin InMS.Read(C, 1); C := (C xor not(ord(Chave shr cnt))); buff.Write(C, 1); end; // buff.SaveToFile('c:\temp\dump.txt') ; finally InMS.free; end; end; </code></pre> <p>--</p> <pre><code> bbuffer := TMemoryStream.Create; try DecryptFile(path, bbuffer, 10); // //ShowMessage(IntToStr(bbuffer.size)); // output : 1000 bbuffer.Position := 0; SL := TStringList.Create; try SL.LoadFromStream(bbuffer); for I := 0 to SL.Count - 1 do // SL.Count = 1 begin; //add each line of orginal file into SL?? end; finally SL.free; end; finally bbuffer.free; end; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload