[Gambas-user] Gambas equivilent help

briansykes brisykes at ...626...
Mon Oct 26 00:16:08 CET 2009


These functions are part of a chat server handshake and they only have it
available to me in java so i have to port it to gambas to use it.

I'll post the big function so you can get an idea of what is going on.

private void n(String s1)
    {
        boolean flag = false;
        String as[] = {
            "MNfw9809", "90981qFS", "412.Fdq.", "..13fS4.", "41!!vs%&"
        };
        StringTokenizer stringtokenizer = new StringTokenizer(s1 + "#",
"#");
        BitSet bitset = new BitSet(64);
        for(int i1 = 0; i1 < 5; i1++)
        {
            BitSet bitset1 = a(as[i1].toCharArray());
            int j1 = Integer.parseInt(stringtokenizer.nextToken());
            for(int l1 = 0; l1 < j1; l1++)
                bitset1 = a(bitset1);

            bitset.xor(bitset1);
        }

        char ac[] = a(bitset, 8);
        for(int k1 = 0; k1 < 8; k1++)
            if(ac[k1] == 0 || ac[k1] == '\n' || ac[k1] == '\r')
                ac[k1] = (char)(ac[k1] | 0x80);

        try
        {
            a_java_io_DataOutputStream_fld.writeBytes("~b#" + 13 + "#");
            for(int i2 = 0; i2 < ac.length; i2++)
                a_java_io_DataOutputStream_fld.write((byte)(ac[i2] & 0xff));

            a_java_io_DataOutputStream_fld.writeBytes("\n");
            a_java_io_DataOutputStream_fld.flush();
            return;
        }
        catch(Exception exception)
        {
            a(exception);
        }
    }

The "MNfw9809", "90981qFS", "412.Fdq.", "..13fS4.", "41!!vs%&" are the
things you have to use when you get the server's handshake request which
looks like this: ~a#50#43#32#21#24#  And from what i can tell the string
array above has to be xor'd with those numbers i think, so thats what i'm
trying to do.


Fabien Bodard-4 wrote:
> 
> 2009/10/25 briansykes <brisykes at ...626...>:
>>
>> Sorry i hit the wrong link, but here it is again. sorry.
>>
>> private BitSet a(char ac[])
>>    {
>>        int i1 = ac.length * 8;
>>        BitSet bitset = new BitSet(i1);
>>        for(int j1 = 0; j1 < i1; j1++)
>>        {
>>            int k1 = j1 & 7;
>>            int l1 = j1 >> 3;
>>            if((ac[l1] & 0xff & 1 << 7 - k1) != 0) ' This is the thing i
>> cant understand.
>>                bitset.set(j1);
>>        }
>>
>>        return bitset;
>>    }
>>
>> Private Function a2(ac As String) as Byte[]
>>
>   Dim i1 as Integer
>   Dim bitset as Byte[]
>   Dim j1 as Integer
>   Dim l1 as Integer
>   Dim k1 as Integer
> 
>   i1 = Len(ac) * 8
>   bitset = New Byte[i1]
>   For j1 = 0 To i1-1
>     k1 = j1 AND 7
>     l1 = Lsr(j1, 3)
>>    'If statement here
>    if cbool(mid(ac,l1)) and $HFF and Lsl(1,7) <>0 then bitset[j1]=true
>>  Next
>>  Return bitset
>>
>> End
>>
> 
> it's a try but i've not the given value.... is it a boolean string ?
> 
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 

-- 
View this message in context: http://www.nabble.com/Gambas-equivilent-help-tp26044750p26052874.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list