Пример #1
0
            public FileInfo(Reader reader)
            {
                byte ss = reader.ReadByte();

                char   buf             = ',';
                string DecryptedString = "";

                for (int i = 0; i < ss; i++)
                {
                    byte b      = reader.ReadByte();
                    int  bufInt = b;

                    bufInt ^= 0xFF;

                    buf             = (char)bufInt;
                    DecryptedString = DecryptedString + buf;
                }

                FileName = DecryptedString;

                //Console.WriteLine(FileName);

                fileSize = reader.ReadUInt32();

                byte[] tmp    = reader.ReadBytes(fileSize);
                int[]  outbuf = new int[fileSize];

                for (int i = 0; i < (int)fileSize; i++)
                {
                    outbuf[i] = tmp[i];
                }

                decryptKeyZ      = ((int)fileSize & 0x1fc) >> 2;
                decryptKeyIndex2 = (decryptKeyZ % 9) + 1;
                decryptKeyIndex1 = (decryptKeyZ % decryptKeyIndex2) + 1;

                decryptKeyIndexZ = 0;

                for (int i = 0; i < (int)fileSize; i++)
                {
                    outbuf[i] ^= decryptKey2[decryptKeyIndex2++] ^ decryptKeyZ;

                    if (decryptKeyIndexZ == 1) // swap nibbles
                    {
                        outbuf[i] = (outbuf[i] >> 4) | ((outbuf[i] & 0xf) << 4);
                    }

                    outbuf[i] ^= decryptKey1[decryptKeyIndex1++];

                    if ((decryptKeyIndex1 <= 19) || (decryptKeyIndex2 <= 11))
                    {
                        if (decryptKeyIndex1 > 19)
                        {
                            decryptKeyIndex1  = 1;
                            decryptKeyIndexZ ^= 1;
                        }
                        if (decryptKeyIndex2 > 11)
                        {
                            decryptKeyIndex2  = 1;
                            decryptKeyIndexZ ^= 1;
                        }
                    }
                    else
                    {
                        decryptKeyZ++;
                        decryptKeyZ &= 0x7F;

                        if (decryptKeyIndexZ != 0)
                        {
                            decryptKeyIndex1 = (decryptKeyZ % 12) + 6;
                            decryptKeyIndex2 = (decryptKeyZ % 5) + 4;
                            decryptKeyIndexZ = 0;
                        }
                        else
                        {
                            decryptKeyIndexZ = 1;
                            decryptKeyIndex1 = (decryptKeyZ % 15) + 3;
                            decryptKeyIndex2 = (decryptKeyZ % 7) + 1;
                        }
                    }
                }
                Filedata = new byte[outbuf.Length];
                for (int i = 0; i < outbuf.Length; i++)
                {
                    Filedata[i] = (byte)outbuf[i];
                }
            }