Exemplo n.º 1
0
        private string DecryptPrivate(string str)
        {
            var receiveData = new List <byte>();

            char[] table = { ' ', '-', '.', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'n' };
            int    count;

            for (count = 0; count < str.Length; count++)
            {
                if (str[count] <= 0x7A)
                {
                    int len = str[count];

                    for (var i = 0; i < len; i++)
                    {
                        count++;

                        try
                        {
                            receiveData.Add(unchecked ((byte)(str[count] ^ 0xFF)));
                        }
#pragma warning disable CA1031 // Do not catch general exception types
                        catch
#pragma warning restore CA1031 // Do not catch general exception types
                        {
                            receiveData.Add(255);
                        }
                    }
                }
                else
                {
                    int len = str[count];
                    len &= 0x7F;

                    for (var i = 0; i < len; i++)
                    {
                        count++;
                        int highbyte = str.Length > count ? str[count] : 0;

                        highbyte  &= 0xF0;
                        highbyte >>= 0x4;

                        int lowbyte = str.Length > count ? str[count] : 0;

                        lowbyte &= 0x0F;

                        if ((highbyte != 0x0) && (highbyte != 0xF))
                        {
                            receiveData.Add(unchecked ((byte)table[highbyte - 1]));
                            i++;
                        }

                        if ((lowbyte != 0x0) && (lowbyte != 0xF))
                        {
                            receiveData.Add(unchecked ((byte)table[lowbyte - 1]));
                        }
                    }
                }
            }

            return(_region.GetEncoding() !.GetString(receiveData.ToArray()));
        }
Exemplo n.º 2
0
        private string DecryptPrivate(string str)
        {
            var receiveData = new List <byte>();

            char[] table = { ' ', '-', '.', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'n' };
            int    count;

            for (count = 0; count < str.Length; count++)
            {
                if (str[count] <= 0x7A)
                {
                    int len = str[count];

                    for (var i = 0; i < len; i++)
                    {
                        count++;

                        try
                        {
                            receiveData.Add(unchecked ((byte)(str[count] ^ 0xFF)));
                        }
                        catch
                        {
                            receiveData.Add(255);
                        }
                    }
                }
                else
                {
                    int len = str[count];
                    len &= 0x7F;

                    for (var i = 0; i < len; i++)
                    {
                        count++;
                        int highbyte;
                        try
                        {
                            highbyte = str[count];
                        }
                        catch
                        {
                            highbyte = 0;
                        }

                        highbyte  &= 0xF0;
                        highbyte >>= 0x4;

                        int lowbyte;
                        try
                        {
                            lowbyte = str[count];
                        }
                        catch
                        {
                            lowbyte = 0;
                        }

                        lowbyte &= 0x0F;

                        if ((highbyte != 0x0) && (highbyte != 0xF))
                        {
                            receiveData.Add(unchecked ((byte)table[highbyte - 1]));
                            i++;
                        }

                        if ((lowbyte != 0x0) && (lowbyte != 0xF))
                        {
                            receiveData.Add(unchecked ((byte)table[lowbyte - 1]));
                        }
                    }
                }
            }

            return(_region.GetEncoding().GetString(receiveData.ToArray()));
        }