Subject | Re: [firebird-support] Re: Need help with FB XOR UDF, please |
---|---|
Author | Chuck Belanger |
Post date | 2005-06-03T20:46:39Z |
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:
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.