Subject RE: [IBO] Varchar with #0 char in it
Author Paul Hope
Ed

I may be wrong but if your encyption routine can produce #0 in the middle of
your data you wont be able to handle it using strings. My only suggestion
would be that you alter your encryption routine to use legal characters
only, or change it to produce something like a string of hex digits.

Regards
Paul

> -----Original Message-----
> From: IBObjects@yahoogroups.com
> [mailto:IBObjects@yahoogroups.com] On Behalf Of Ed Dressel
> Sent: 14 March 2008 15:45
> To: IBObjects@yahoogroups.com
> Subject: Re: [IBO] Varchar with #0 char in it
>
> > I'm not sure if it is pertinent, but are you referring to the field
> > using .Value or .AsString? The .Value method does save
> extra code in
> > loops but the downside is it accesses the values as variants and
> > relies on Delphi to do the casting. That does increase the risk of
> > undesired effects such as (possibly) the encounter with the ascii-
> > zero causing the string to be interpreted as null-terminated. I
> > always use the casting methods where possible...
>
> here is my code:
>
> procedure TdmDatabase.SetEncryptedFieldText(Sender: TField; const
> Text: String);
> var
> lID: Integer;
> begin
> if Sender.DataSet.FieldByName('Encrypted').AsBoolean then
> begin
> lID := ...
> if not (Sender.Dataset.State in dsEditModes) then
> Sender.Dataset.Edit;
>
> Sender.AsString :=
> GeneralFunctions.GetEncryptedData(Text, lID, ...);
> end;
> end;
>
> any other ideas?
>
> Ed Dressel
>
>
> ------------------------------------
>
> ______________________________________________________________
> _____________
> IB Objects - direct, complete, custom connectivity to
> Firebird or InterBase
> without the need for BDE, ODBC or any other layer.
> ______________________________________________________________
> _____________
> http://www.ibobjects.com - your IBO community resource for
> Tech Info papers,
> keyword-searchable FAQ, community code contributions and more
> ! Yahoo! Groups Links
>
>
>