Help create function that checks for this pattern?

Put your programming skills to the test in these challenges.

Help create function that checks for this pattern?

Post by JoshGlzBrk on Fri Jan 22, 2010 2:46 am
([msg=33732]see Help create function that checks for this pattern?[/msg])

So I have a function that generates an array of 6 bytes, and they are generated using a certain algorithm shown in the code below, it's in C#, but it's almost identical to c++ version.

Basically I just need a function that can check an array of 6 bytes to see if it's possible they were generated using this function below.

Also note, integer "op" is always 0.

Code: Select all
static public void calculate(ref byte[] aad, int op)
        {
            for (int j = 0; j < 6; j++)
            {
                Random Rand = new Random();
                aad[j] = (byte)Rand.Next(0, 255);
                int n;
                int i;
                int ofs;
                byte d;

                aad[3 + op] = (byte)(aad[1 + op] ^ aad[2 + op] ^ aad[4 + op]);
                aad[0 + op] = (byte)((aad[4 + op] ^ aad[1 + op]) + aad[2 + op]);
                aad[5 + op] = 0;
                d = (byte)0xd5;

                for (n = 0, ofs = 2; n < 17; n++, ofs += 6)
                {
                    for (i = -2; i <= 3; i++)
                    {
                        d = aad[op + ((ofs + i) % 6)] = (byte)(((ofs + i) % 5 != 0) ? aad[op + ((ofs + i) % 6)] + d : aad[op + ((ofs + i) % 6)] ^ d);
                    }
                }
            }
        }

JoshGlzBrk
New User
New User
 
Posts: 1
Joined: Fri Jan 22, 2010 2:44 am
Blog: View Blog (0)


Re: Help create function that checks for this pattern?

Post by tgoe on Fri Jan 22, 2010 3:55 am
([msg=33734]see Re: Help create function that checks for this pattern?[/msg])

What is this for, exactly?
User avatar
tgoe
Contributor
Contributor
 
Posts: 650
Joined: Sun Sep 28, 2008 2:33 pm
Location: q3dm7
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests