Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Base64 in http_response

Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
06-14-2007 11:22
I've got a script which is using a relatively simple base64 encryption for one-time messages (it never re-uses keys).

The weird thing I'm getting is that while one object I have can happily send and receive base64 encoded messages, the other one receives them (and when printing using llOwnerSay looks perfect), but when it decrypts them it gets a blank result.

The decryption code is simple:
CODE
string decryptMessage(string message) { // Take a base64 message
return llBase64ToString(llXorBase64StringsCorrect(message, encryptionKey));
}


Now, if I copy values into the function in state_entry() or another script or whatever, it works perfectly, but when running live with messages from the web-site, it seems to be failing, even though if I print the messages they are exactly what they should be.
I'm wondering if this is an encoding issue, is there any specific encoding I should be returning in my PHP scripts?
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
AnnMarie Otoole
Addicted scripter
Join date: 6 Jan 2007
Posts: 162
06-14-2007 13:12
First thing I would check is for leading/trailing or embedded non-printing characters.
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
06-14-2007 14:01
Which are the non-printable characters? In the LSL wiki it only seems to list them as integer values which isn't especially helpful.

An example pair of messages would be:
Encryption: M2IxOWUyYTQ5OWQyOWRlNWQzYWYzZjBiMGUxMDNiYzBhOTg1N2IyMTY3ODY0YTU1NGI5ZDgzM2YyNTA1MDRmMTIwYjI1YWI5Yjg5N2EzM2M4NDdhOTcyNDE0N2U2NzM4NjQ4NThhZmQxNDY2ZjcxNDY5YzAyMjZiODRhM2RhYmU=
Message:
YDdyeiBhMgUUDUkDFFU=

(Sorry if this makes the page scroll for some people)

These are from an older message format and give the following output:
SUCCESS1-4-1-1

However, despite the fact that these values if copy/pasted into my script as constants and run in the state_entry() through my decryptMessage steps, these don't work if they are received via HTTP. As you can see though, these strings were taken from llOwnerSay() commands and don't appear to have an faults in them.
But when I run it in http_response() I get absolute nothing when decrypting it.
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
06-14-2007 14:08
Try running an llStringTrim on the string that is being read int from the HTTP response before it gets parsed by the Base64ToString?

I agree with AnnMarie it sounds like the Web server is adding in some characters that the convert process can't deal with.
ninjafoo Ng
Just me :)
Join date: 11 Feb 2006
Posts: 713
06-14-2007 15:22
Ive had the same problem getting encrypted data from a webserver - llStringTrim was the fix
_____________________
FooRoo : clothes,bdsm,cages,houses & scripts

QAvimator (Linux, MacOS X & Windows) : http://qavimator.org/
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
06-15-2007 03:57
Argh, now I just feel stupid, I found the rogue space after the ?> tag in one of my included files *slaps head*
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)