A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Flash and asp using post method

  1. #1
    Member
    Join Date
    Sep 2000
    Posts
    50
    HI,
    I have a game which needs interaction with the server for score submission and login validation.
    I have achieved the same thru '
    Flash --> ASP --> SQL
    This works fine if the variables are submitted with 'GET' method. ASP is inturn sending back the variables using the response.write method. But if I change the variables sending method to "POST' then the same does not seem to work.
    I have checked the asp file and it works fine.
    So theres seems to be some problem with the flash's post method.
    Can one of the kind souls out there help me with the above problem as i necessarily need to keep the info hidden and cannot send it with the get method.
    if at all theres a better method like the https method and somebody knows about it then great. But I need help immediately. Is it because of the response.write statement in asp that is not recognised by flash. I am using pws for testing.
    Thanks and waiting for a response immediately,
    Naveen

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    there seem to be a few constellations where client browser X, possibly client OS Y and server Z do not really work together. A particular one: flash plugin for all netscape browsers (any OS) generates bad data with post, which Apache server knows to handle and microsoft servers refuse to accept. There may be others as well.
    One alternative would be to optionally encrypt and then encode (e.g. base 64) your data and use it as a URL
    Whoever goes into the AS to find out how the encoding was done would probably also understand to intercept POST messages sent in clear

    Musicman

  3. #3
    Member
    Join Date
    Sep 2000
    Posts
    50
    HI Musicman,
    Thanks for replying. Correct me if i am wrong... this is what you mean...

    step 1 :encrypt the data being sent by the flash movie
    step 2 : decrypt the data in asp
    step 3 : read from/write to the database.

    Is this what you mean ? and what is base 64 encryption?
    Hope to hear from you at the earliest
    ps: I am testing the post method on microsoft pws

    Naveen

  4. #4
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    yes, something like that...
    Base64 is not really an encryption, but rather an encoding. It turns a string of arbitrary characters (including unprintable ones) that might be the outcome of encryption into a somewhat longer string of printable characters.
    Since this is a standard method (it is used for server - not script - based protection as well as for including images in email) it should be no problem to find e.g. a decoder function in asp.
    Using base64 on
    user=john&pass=secret&score1=593
    would give you a string
    dXNlcj1qb2huJnBhc3M9c2VjcmV0JnNjb3JlMT010TM=
    If you do some encryption as well, the string that is actually sent will still look like gibberish ... but someone who recognizes or guesses base64 will get gibberish again after decoding it.
    Unless you are protecting really sensitive stuff, a simple encryption would do. But - please do not use base64, crypt, cipher etc. as function names in your actionscript

    Musicman

  5. #5
    Member
    Join Date
    Sep 2000
    Posts
    50
    HI,
    But how do i encode the variables i am sending to base 64 in flash??
    Thats one thing i am not able to figure out..
    naveen

  6. #6
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi naveen,

    this is base64 encoder translated from another language
    Code:
    tab1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
    function b64(txt)
    {       var res = '';
            var i, c1, c2, c3;
            for(i = 0 ; i < txt.length ; i += 3)
            {       c1 = txt.charCodeAt(i);
                    c2 = txt.charCodeAt(i+1);
                    c3 = txt.charCodeAt(i+2);
                    res += tab1.charAt(c1 >> 2);
                    res += tab1.charAt(((c1 & 3) << 4) + (c2 >> 4));
                    if(i == txt.length-2)
                            res += '=';
                    else
                            res += tab1.charAt(((c2 & 0xf) << 2) + (c3 >> 6));
                    if(i <= txt.length-1)
                            res += '=';
                    else
                            res += tab1.charAt(c3 & 0x3f);
            }
            return res;
    }
    Note this code is using a text string as input, like a set of flash variables. If you want to use it with the output of an encryption that might produce null chars, replace the text by an array and the txt.charCodeAt(x) by ary[x]. Also make sure that the encrytion will only store positive values in the array.

    Musicman

  7. #7
    Member
    Join Date
    Sep 2000
    Posts
    50
    Hi Musicman,
    Thanks for replying. I got the logic. I will keep in touch if i need anymore help.
    Thanks and best,
    Naveen

  8. #8
    Member
    Join Date
    Sep 2000
    Posts
    50
    Hi Musicman,
    I got the way out of this as far as the encoding part is concerned. But can you give me the source code for decoding base64 info in flash. That would really help me.
    I feel you should think of writing a technote about this..
    anyways waiting for your response.
    Thanks and best,
    Naveen

  9. #9
    Member
    Join Date
    Sep 2000
    Posts
    50
    Hi,
    Can anybody send me asp and fla files wherein the post method is being used and is working perfectly.
    Thanks and best,
    Naveen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center