## 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?

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

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

### Re: Help create function that checks for this pattern?

What is this for, exactly?

tgoe
Contributor

Posts: 715
Joined: Sun Sep 28, 2008 2:33 pm
Location: q3dm7
Blog: View Blog (0)