Subject | RE: [firebird-support] Re: Need help with FB XOR UDF, please |
---|---|
Author | Kevin Day Programming |
Post date | 2005-06-05T23:37:46Z |
Don't forget to use CDECL or STDCALL for the procedure calling convention
for UDF's.
Regards,
Kevin.
for UDF's.
Regards,
Kevin.
> -----Original Message-----
> From: firebird-support@yahoogroups.com
> [mailto:firebird-support@yahoogroups.com]On Behalf Of Chuck Belanger
> Sent: Saturday, 4 June 2005 6:47 AM
> To: firebird-support@yahoogroups.com
> Subject: Re: [firebird-support] Re: Need help with FB XOR UDF, please
>
>
> Hi, Leonardo:
>
> Thank you very much for taking the time to reply.
>
> I used your XOR procedure and the UDF declaration but am getting the same
> type of problem:
>
> Each time I call Str2Str, I get a different return value. This seems to
> cycle anywhere from 2-4 times then repeats the pattern. I have no idea
> what's going on here. The original function works just fine in a Delphi
> app. I continue to suspect there is something about using PChar vs String
> that make the difference.
>
> In any case I still can't get 'hello' back with your new procedure as in:
>
> SELECT FIRST 1 F_STR2STR(F_STR2STR('hello', 1234),1234) FROM TABLE
>
> I'm assuming that the above checks both obscuring and de-obscuring (I'm
> deliberately not saying encrypt/decrypt :) )
>
> I have very little experience working with PChars so if you or anyone
> else has further suggestions, please do so.
>
> Thanks,
>
> Chuck Belanger
>
> Leonardo Cosmai wrote:
>
> > Hi, try this:
> >
> > procedure Str2Str(Value:PChar; Key: integer; ValueOut:PChar);
> > var
> > P : PChar;
> > begin
> >
> > RANDSEED := Key;
> > P := Value;
> >
> > while P^ <> #0 do begin
> > ValueOut^ := Chr(Ord(P^) XOR (RANDOM(254)+1));
> > Inc(P);
> > Inc(ValueOut);
> > end;
> >
> > ValueOut^ := #0;
> >
> > end;
> >
> > and declare it with:
> >
> > DECLARE EXTERNAL FUNCTION F_STR2STR
> > CSTRING(3072),
> > INTEGER,
> > CSTRING(3072)
> > RETURNS PARAMETER 3
> > ENTRY_POINT 'Str2Str' MODULE_NAME 'FreeUDFLib.dll'
> >
> > Ciao.
> > L.
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>
>
>