<div dir="ltr">Hello guys<div><br></div><div>I´ve a single code to encrypt/decrypt strings using Blowfish.</div><div><div><br></div><div>function TBlowFishCripto.Encrypt(const Value: string): string;</div><div>var</div><div> en: TBlowFishEncryptStream;</div><div> stream: TStringStream;</div><div>begin</div><div> if length(Value) = 0 then</div><div> begin</div><div> Result := '';</div><div> Exit;</div><div> end;</div><div> try</div><div> stream := TStringStream.Create('');</div><div> en := TBlowFishEncryptStream.Create(FKey, stream);</div><div> en.Write(Value[1], Length(Value));</div><div> Result := stream.DataString;</div><div> finally</div><div> FreeAndNil(en);</div><div> FreeAndNil(stream);</div><div> end;</div><div>end; </div><div><br></div><div><div>function TBlowFishCripto.Decrypt(const encrypted: string;</div><div> out decrypted: string): boolean;</div><div>var</div><div> de: TBlowFishDeCryptStream;</div><div> s2: TStringStream;</div><div> decr: string;</div><div>begin</div><div> if length(encrypted) = 0 then</div><div> begin</div><div> Result := True;</div><div> decrypted := '';</div><div> Exit;</div><div> end;</div><div><br></div><div> { 4 }</div><div> s2 := TStringStream.Create(encrypted);</div><div> { 5 }</div><div> de := TBlowFishDeCryptStream.Create(FKey, s2);</div><div> { 6 }</div><div> decr := de.ReadAnsiString;</div><div><br></div><div> de.Free;</div><div> s2.Free;</div><div><br></div><div> decrypted:=decr;</div><div> REsult:=true;</div><div><br></div><div> FreeAndNil(de);</div><div> FreeAndNil(s2);</div><div>end; </div></div><div><br></div><div>When the method Decrypt runs with a argument 'encrypted' with a string returned by the method Encrypt, it raise an exception 203 on line after {6} </div><div>I don´t know how to debug this.</div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><i>Timeo hominem unius libri</i><br><br>[]s<br>Guionardo Furlan<br><a href="http://www.guionardofurlan.com.br" target="_blank">http://www.guionardofurlan.com.br</a></div></div>
</div></div>