namespace VaioxOnline
{
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.IO;
    using System.Net;
    using System.Security.Cryptography;
    using System.Text;

    public class MyFunction
    {
        public int CountPatches(string s)
        {
            WebClient client = new WebClient();
            char[] separator = new char[] { '\r' };
            int length = client.DownloadString(s).Split(separator).Length;
            return (length - 1);
        }

        public string Decrypt(string strText)
        {
            string message;
            string str2 = "c8YXEft&+fMs@]ntv2!JyUuFs[#xgXek";
            byte[] rgbKey = new byte[0];
            byte[] rgbIV = new byte[] { 0x33, 0x62, 0x57, 0x33, 0x23, 0x40, 0x6a, 0x75, 0x72, 0x5b, 0x5f, 0x42, 80, 0x55, 0x76, 0x73 };
            byte[] buffer = new byte[strText.Length + 1];
            try
            {
                rgbKey = Encoding.UTF8.GetBytes(str2.Substring(0, 0x10));
                RijndaelManaged managed = new RijndaelManaged();
                buffer = Convert.FromBase64String(strText);
                MemoryStream stream = new MemoryStream();
                CryptoStream stream2 = new CryptoStream(stream, managed.CreateDecryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
                stream2.Write(buffer, 0, buffer.Length);
                stream2.FlushFinalBlock();
                message = Encoding.UTF8.GetString(stream.ToArray());
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                message = exception.Message;
                ProjectData.ClearProjectError();
            }
            return message;
        }

        public string Encrypt(string strText)
        {
            string message;
            string str2 = "c8YXEft&+fMs@]ntv2!JyUuFs[#xgXek";
            byte[] rgbKey = new byte[0];
            byte[] rgbIV = new byte[] { 0x33, 0x62, 0x57, 0x33, 0x23, 0x40, 0x6a, 0x75, 0x72, 0x5b, 0x5f, 0x42, 80, 0x55, 0x76, 0x73 };
            try
            {
                rgbKey = Encoding.UTF8.GetBytes(str2.Substring(0, 0x10));
                RijndaelManaged managed = new RijndaelManaged();
                byte[] bytes = Encoding.UTF8.GetBytes(strText);
                MemoryStream stream = new MemoryStream();
                CryptoStream stream2 = new CryptoStream(stream, managed.CreateEncryptor(rgbKey, rgbIV), CryptoStreamMode.Write);
                stream2.Write(bytes, 0, bytes.Length);
                stream2.FlushFinalBlock();
                message = Convert.ToBase64String(stream.ToArray());
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                message = exception.Message;
                ProjectData.ClearProjectError();
            }
            return message;
        }

        public string MD5StringHash(string strString)
        {
            MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
            string str2 = "";
            string expression = "";
            byte[] bytes = Encoding.ASCII.GetBytes(strString);
            byte[] buffer2 = provider.ComputeHash(bytes);
            int num = buffer2.Length - 1;
            for (int i = 0; i <= num; i++)
            {
                expression = Conversion.Hex(buffer2[i]);
                if (Strings.Len(expression) == 1)
                {
                    expression = "0" + expression;
                }
                str2 = str2 + expression;
            }
            return str2;
        }
    }
}

