Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables Equal .. but Different ?

Status
Not open for further replies.

vazagothic

Programmer
May 19, 2004
32
US
Hello All,
I've encountered a weird problem while trying to make a Xceed Encryption Library v1.1 work (an ActiveX dll). I know they say on the web site, that it doesn't support VFP, but I believe there is a way to make it work :)

Anyway, my problem is as follow - in short (and making it simpiler):
I have a variable (gcPublicKey), which contains binary data. I want to store its content to a file, so I can use it later.

I try to decipher the content of a file using ASC() function and then store the result in a file, so I can recreate it.

When I read the content of the file and store it in a vaPublicKey, the following conditions return true:
[red]
(gcPublicKey == vaPublicKey)
(LEN(gcPublicKey) = LEN(vaPublicKey))
[/red]
But when I feed the ActiveX with this recreated string I get an error - something has to be wrong with it.

I can cut create new variable by adding two slices of gcPublicKey, I can assign it to another variable and the output still works.

But when I try to copy the content of gcPublicKey using:
[red]
vaPublicKey = ""
FOR I = 1 TO LEN(gcPublicKey)
t = SUBSTR(gcPublicKey,i,1)
vaPublicKey = vaPublicKey + t
ENDFOR
[/red]
I get the same problem as I did before.

Is there another way to disassemble first string so I can store it in exactly the same way ?
 
Well - I found a solution to my problem, but it is EXTREMLY weird!

When I do this:

[red]
lcDummyPart = LEFT(gcPublicKey,0) && Add 0 bytes from the Dummy Key
lcGoodKeyPart = SUBSTR(vaPublicKey, 1) && Append it with the good key
gcPublicKeyFinal = lcDummyPart + lcGoodKeyPart
[/red]

The gcPublicKeyFinal works fine. Any ideas why ? Since I am appending the vaPublicKey (the one I was having problems before) with an EMPTY string.
 
It maybe that it is prepending a chr(0) to the string. Just a guess...try using chr(0) instead of the lcDummyPart and see if the results are the same for you.

boyd.gif

 
Vazagothic,

I think Craig might be on the right track here.

My own guess is that this is something to do with the way that the length of the string is determined. In some languages, strings are pre-pended with a binary number which indicates their length. In others, the string is terminated with a "null", that is, a binary zero. It could be that there is some kind of mismatch in the two systems here. But it's just a guess.

Mike

Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
I found that the string I was receiving was of VarBinary/BLOB type which is somewhat supported by VFP8 (the code doesn't even work in VFP6).

I did test it with VFP9 Beta and the TYPE() function returned 'Q'.
 
And to answer the question. It doesn't work when you add CHR(0) in front/back nor add "0h" to the string (that's the way VFP9 marks a BLOB/VarBinary type)

I believe VFP8 doesn't fully support BLOBs - that's why there is a problem with processing them.

Also - is there a way to FORCE variable to be of a binary type ? Like a TRANSFORM or so ? I didn't find anything like that in VFP9 documentation.

Like, I do have:
a = "305A"
but I want to have b = "0h305A" as a BLOB.
 
Ok, found it - and it even fixed my problem with VFP8.

The function is called CREATEBINARY() :)

Thanks for all your help and for pointing me into the right direction :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top