#1 2011-12-15 14:00:59

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Advince for save RTF text and password inside the database

Hi,

1) I need save a RTF text inside my database. I both TRichEdit (delphi component) and TRichView (commercial component) as source of my RTF test.

Until now I use a BLOB field and this code:

  function GetRTFEditStream(RE: TRichEdit): TStringStream;
  var
    strStream: TStringStream;
  begin
    strStream := TStringStream.Create('') ;
    RE.Lines.SaveToStream(strStream);
    if (strStream <> nil) then
      strStream.Seek(0, soFromBeginning) ;
    Result := strStream;
  end;

In this way I can save/load the RTF without problem but I need use a BLOB field.

Do you think is there a way to avoid to use a BLOB field?

2) On my application I need save some passwords. Note, I don't use this password to user login (in this case in fact I can save the hash). These password are some website password so the user need save them and load them as clear text. In this moment I use a TSQLRawBlob field to save them and the Cypher function to crypth/decryph them.
Is there a fast and safe (not clear) way to save/load on db?

Sorry for these question but I'd like remove all TSQLRawBlob field if not strictly necessary.

Last edited by array81 (2011-12-15 14:48:30)

Offline

#2 2011-12-15 16:33:41

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Advince for save RTF text and password inside the database

1) RTF is plain text, so you could also use RawUTF8 or WinAnsiString, if the embedded pictures are not in binary format.

2) You can use Base64 encoding (there are functions in SynCommons.pas) then store the password as RawUTF8.

Offline

Board footer

Powered by FluxBB