Problem solved. A friend advert me to the fact I can't use the  same
TMemoryStream for input and output.

This is the correct code:

program test;
{$mode objfpc}{$H+}

uses
blowfish, classes;

var
VInput, VOutput: TMemoryStream;
VCypher: TBlowfishEncryptStream;
BEGIN
VInput := nil;
VOutput := TMemoryStream.create;
VCypher := TBlowfishEncryptStream.create('lazarus-br', VOutput);
try
VInput := TMemoryStream.create;
VInput.LoadFromFile('origin.txt');
VCypher.writebuffer(VInput.memory, VInput.size);
VOutput.SaveToFile('output.bfe');
finally
VCypher.free;
VInput.free;
VOutput.free;
end;
END.

2015-12-01 17:57 GMT-02:00, luciano de souza <luchya...@gmail.com>:
> Hello all,
>
> What's wrong with this code?
>
> I try to cryptograph a file. The compiler doesn't raise errors, but
> after running the program, no results happen.
>
> program test;
> {$mode objfpc}{$H+}
>
> uses
> blowfish, classes;
>
> var
> VMemory: TMemoryStream;
> VCypher: TBlowfishEncryptStream;
> BEGIN
> VMemory := TMemoryStream.create;
> VMemory.LoadFromFile('origin.txt');
> VCypher := TBlowfishEncryptStream.create('lazarus-br', VMemory);
> try
> VMemory.position := 0;
> VCypher.write(VMemory.memory, VMemory.size);
> VMemory.SaveToFile('output.bfe');
> finally
> VCypher.free;
> VMemory.free;
> end;
> END.
>
> --
> Luciano de Souza
>


-- 
Luciano de Souza
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to