Exemple #1
0
 /// <summary>
 /// Generates IFC GUID from not empty string.
 /// </summary>
 /// <param name="uniqueString">String which should uniquely identify IFC entity.</param>
 /// <returns>String in IFC GUID format. Uniqueness is highly likely, but not guaranteed even if input string is unique.</returns>
 public static string GenerateIFCGuidFrom(string uniqueString)
 {
     byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(uniqueString));
     return(ConvertToIFCGuid(new Guid(hash)));
 }
Exemple #2
0
        private static bool Load(string fileName)
        {
            using (FileStream compressedStream = new FileStream(fileName, FileMode.Open))
                using (DeflateStream deflateStream = new DeflateStream(compressedStream, CompressionMode.Decompress, true))
                    using (MemoryStream stream = new MemoryStream())
                        using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
                        {
                            int hashSize = md5.HashSize / 8;

                            deflateStream.CopyTo(stream);

                            stream.Seek(0L, SeekOrigin.Begin);

                            byte[] currentHash = new byte[hashSize];
                            stream.Read(currentHash, 0, hashSize);

                            byte[] expectedHash = md5.ComputeHash(stream);

                            if (!CompareHash(currentHash, expectedHash))
                            {
                                InvalidateCompressedStream(compressedStream);

                                return(false);
                            }

                            stream.Seek((long)hashSize, SeekOrigin.Begin);

                            Header header = ReadHeader(stream);

                            if (header.Magic != HeaderMagic)
                            {
                                InvalidateCompressedStream(compressedStream);

                                return(false);
                            }

                            if (header.CacheFileVersion != InternalVersion)
                            {
                                InvalidateCompressedStream(compressedStream);

                                return(false);
                            }

                            if (header.FeatureInfo != GetFeatureInfo())
                            {
                                InvalidateCompressedStream(compressedStream);

                                return(false);
                            }

                            if (header.InfosLen % InfoEntry.Stride != 0)
                            {
                                InvalidateCompressedStream(compressedStream);

                                return(false);
                            }

                            byte[] infosBuf       = new byte[header.InfosLen];
                            byte[] codesBuf       = new byte[header.CodesLen];
                            byte[] relocsBuf      = new byte[header.RelocsLen];
                            byte[] unwindInfosBuf = new byte[header.UnwindInfosLen];

                            stream.Read(infosBuf, 0, header.InfosLen);
                            stream.Read(codesBuf, 0, header.CodesLen);
                            stream.Read(relocsBuf, 0, header.RelocsLen);
                            stream.Read(unwindInfosBuf, 0, header.UnwindInfosLen);

                            try
                            {
                                PtcJumpTable = (PtcJumpTable)_binaryFormatter.Deserialize(stream);
                            }
                            catch
                            {
                                PtcJumpTable = new PtcJumpTable();

                                InvalidateCompressedStream(compressedStream);

                                return(false);
                            }

                            _infosStream.Write(infosBuf, 0, header.InfosLen);
                            _codesStream.Write(codesBuf, 0, header.CodesLen);
                            _relocsStream.Write(relocsBuf, 0, header.RelocsLen);
                            _unwindInfosStream.Write(unwindInfosBuf, 0, header.UnwindInfosLen);

                            return(true);
                        }
        }
Exemple #3
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                String email = textBox1.Text;
                String senha = textBox2.Text;



                //////////////CONVERTE A SENHA PARA MD5 ////////////////
                System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
                byte[] inputBytes            = System.Text.Encoding.ASCII.GetBytes(senha);
                byte[] hash                  = md5.ComputeHash(inputBytes);
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                for (int i = 0; i < hash.Length; i++)
                {
                    sb.Append(hash[i].ToString("X2"));
                }
                String senha_encriptada_maiuscula = sb.ToString();                        //pega o resultado
                String senha_encriptada           = senha_encriptada_maiuscula.ToLower(); //coloca o resultado em letras minúsculas

                // MessageBox.Show(senha_encriptada); //teste


                //////////////CONVERTE A SENHA PARA MD5 ////////////////



                string caminhodb = "Server=127.0.0.1;DATABASE=" + bd_nome + ";UID=" + bd_user + ";PASSWORD="******"";
                conexao = new MySqlConnection(caminhodb); //tentar uma conexão
                conexao.Open();                           //abrir banco


                var pesquisa = "SELECT Email, Nome, ID_Usuario, Foto, Senha FROM usuario WHERE Email LIKE  '" + email + "' AND Senha LIKE '" + senha_encriptada + "' ";

                MySqlCommand    comando = new MySqlCommand(pesquisa, conexao);
                MySqlDataReader leitor;
                leitor = comando.ExecuteReader();



                //enquanto leitor lê
                while (leitor.Read())
                {
                    String Email      = leitor["Email"].ToString();
                    String Nome       = leitor["Nome"].ToString();
                    String ID_Usuario = leitor["ID_Usuario"].ToString();
                    String Foto       = leitor["Foto"].ToString();
                    String Senha      = leitor["Senha"].ToString();

                    //  MessageBox.Show(Senha);


                    textBox3.Text = email;



                    //MessageBox.Show(Email + "  " + Nome + "  " + ID_Usuario + "   " + Foto); //teste

                    Usuario.Email      = Email;
                    Usuario.Nome       = Nome;
                    Usuario.ID_Usuario = ID_Usuario;
                    Usuario.Foto       = Foto;
                    Usuario.Senha      = Senha;



                    FrmSplash frmInicio = new FrmSplash();
                    frmInicio.Show();

                    this.Hide();
                }

                if (textBox3.Text == "")
                {
                    MessageBox.Show("Usuário inexistente", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                }
            }

            catch (Exception)
            {
                conexao.Close();
                MessageBox.Show("Erro", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #4
0
 private static String MD5Checksum(String data)
 {
     System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
     return(BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(data))).Replace("-", ""));
 }
Exemple #5
0
 private string targetHash(string message)
 {
     byte[] target = Target.ComputeHash(System.Text.Encoding.UTF8.GetBytes(message));
     return(BitConverter.ToString(target).Replace("-", string.Empty));
 }
Exemple #6
0
 static string SignVenusRequest(string postData, string secret)
 {
     System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
     byte[] bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(string.Format("{0}{1}", postData, secret)));
     return(Convert.ToBase64String(bytes, 0, bytes.Length));
 }
Exemple #7
0
        private void MineThroughText(string FilePath, string Cluster)
        {
            StreamReader            Reader       = new StreamReader(FilePath);
            uint                    LineCounters = 0;
            List <DistributionList> DistList     = new List <DistributionList>();

            if ("" == txtLinesToSample.Text.Trim())
            {
                txtLinesToSample.Text = "100";
            }

            while (!Reader.EndOfStream && LineCounters < Convert.ToInt32(txtLinesToSample.Text))
            {
                string   pattern     = "";
                string   LinePattern = "";
                string   strText     = "";
                string[] tokens;

                // read line
                strText = Reader.ReadLine();
                LineCounters++;
                rtbOpenFile.Text = rtbOpenFile.Text + "\n" + strText;

                // string to token
                tokens = strText.Split(new Char[] { ' ', ',', '\t' });

                // Find pattern in each token
                foreach (string token in tokens)
                {
                    if (token != "")
                    {
                        string tempPattern = ConvertRegEx(token);

                        if (pattern != "Text")
                        {
                            pattern     = tempPattern;
                            LinePattern = LinePattern + " " + pattern;
                        }
                        else if (tempPattern != "Text")
                        {
                            pattern     = tempPattern;
                            LinePattern = LinePattern + " " + pattern;
                        }
                    }
                }

                rtbRegEx.Text = rtbRegEx.Text + "\n" + LinePattern;
                DistributionList Line = DistList.Find(
                    delegate(DistributionList DL)
                {
                    return(DL.Line == LinePattern);
                }
                    );

                if (Line != null)
                {
                    Line.Frequency++;
                }
                else
                {
                    DistributionList Item = new DistributionList();
                    Item.Line      = LinePattern;
                    Item.Frequency = 1;
                    DistList.Add(Item);
                }
            }
            Reader.Close();

            rtbPattern.Text = rtbFrequency.Text = "";
            //DistList.Sort();
            foreach (DistributionList T in DistList)
            {
                rtbPattern.Text   = rtbPattern.Text + "\n" + T.Line;// +"::" + T.Frequency;
                rtbFrequency.Text = rtbFrequency.Text + "\n" + T.Line + "::" + T.Frequency;
            }

            string hash;
            string fhash;

            using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
            {
                hash = BitConverter.ToString(
                    md5.ComputeHash(Encoding.UTF8.GetBytes(rtbFrequency.Text))
                    ).Replace("-", String.Empty);
            }

            using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
            {
                fhash = BitConverter.ToString(
                    md5.ComputeHash(Encoding.UTF8.GetBytes(rtbPattern.Text))
                    ).Replace("-", String.Empty);
            }

            //Check DB
            SqlCeConnection Conn = new SqlCeConnection(@"Data Source=C:\Users\achinbha\SkyDrive\Code-Project\Str2RegEx\Str2RegEx\Sampler.sdf");

            Conn.Open();
            SqlCeCommand    Command    = new SqlCeCommand("Select * from SampleDB WHERE Hash='" + hash + "'", Conn);
            SqlCeDataReader DataReader = Command.ExecuteReader();

            //If pattern exist in DB, update its frequency
            // Else insert to DB
            if (DataReader.Read())
            {
                lblCluster.Text   = "Cluster: " + DataReader.GetString(0);
                lblHash.Text      = "Hash: " + DataReader.GetString(1);
                lblFrequency.Text = "Frequency: " + DataReader[2].ToString();

                SqlCeDataAdapter Adapter = new SqlCeDataAdapter(Command);
                Adapter.UpdateCommand = new SqlCeCommand("UPDATE SampleDB SET Frequency=" + (Convert.ToInt32(DataReader[2].ToString()) + 1) + "WHERE Hash = '" + hash + "'", Conn);
                Adapter.UpdateCommand.ExecuteNonQuery();
            }
            else
            {
                lblCluster.Text = "Cluster: " + Cluster;
                lblHash.Text    = "Hash: " + hash;

                //
                // TODO:
                // Check with user for Cluster name if not provided
                //
                SqlCeDataAdapter Adapter = new SqlCeDataAdapter(Command);
                Adapter.UpdateCommand = new SqlCeCommand("Insert into SampleDB (Cluster, Hash, Frequency, Stack) Values ('" + Cluster + "', '" + hash + "', 0, '')", Conn);
                lblFrequency.Text     = "Frequency: " + Adapter.UpdateCommand.ExecuteNonQuery();
            }
            dataGridView1.Refresh();
            DataReader.Close();
            Conn.Close();

            bool flag = false;

            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                if (dataGridView1.Rows[i].Cells[1].Value.ToString() == hash)
                {
                    dataGridView1.ClearSelection();
                    flag = true;
                    int Frequency = Convert.ToInt32(dataGridView1.Rows[i].Cells[2].Value.ToString());
                    Frequency = Frequency + 1;
                    dataGridView1.Rows[i].Cells[2].Value = Frequency;
                    dataGridView1.Rows[i].Selected       = true;
                    break;
                }
            }

            if (flag == false)
            {
                //dataGridView1.Rows.Add(hash, 0, Cluster,"");
            }
        }
 public static byte[] MD5(byte[] data)
 {
     lock (MD5Builder)
         return(MD5Builder.ComputeHash(data));
 }
Exemple #9
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            if (!Input.Email.EndsWith("@mvla.net"))
            {
                ModelState.AddModelError(string.Empty, "Not a valid MVLA email address!");
                return(Page());
            }

            returnUrl ??= Url.Content("~/");
            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
            if (ModelState.IsValid)
            {
                StringBuilder sb = new StringBuilder();
                using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
                {
                    byte[] inputBytes = Encoding.ASCII.GetBytes(Input.Email.Trim().ToLower());
                    byte[] hashBytes  = md5.ComputeHash(inputBytes);

                    for (int i = 0; i < hashBytes.Length; i++)
                    {
                        sb.Append(hashBytes[i].ToString("X2"));
                    }
                }

                var user = new ContraUser {
                    Name = Input.Name,

                    Articles       = new List <Article>(),
                    ArticlesLiked  = new List <Article>(),
                    ArticlesViewed = new List <Article>(),
                    CommentsLiked  = new List <Comment>(),

                    ProfilePictureURL = "https://gravatar.com/avatar/" + sb.ToString() + "?d=identicon",
                    UserName          = Input.Email,
                    Email             = Input.Email,
                    DateJoined        = DateTime.Now
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { area = "Identity", userId = user.Id, code },
                        protocol: Request.Scheme);

                    await _emailSender.SendConfirmEmailAsync(Input.Email, Input.Name, callbackUrl);

                    if (_userManager.Options.SignIn.RequireConfirmedAccount)
                    {
                        return(RedirectToPage("RegisterConfirmation", new { email = Input.Email }));
                    }
                    else
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        return(LocalRedirect(returnUrl));
                    }
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
        private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            this.contextMenuStripTreeNode.Items.Clear();
            if (e.Button == MouseButtons.Right && e.Node != null)
            {
                var selectedNode = e.Node;
                treeView1.SelectedNode = selectedNode;
                if (selectedNode.Parent != null) //file node selected
                {
                    ToolStripMenuItem menu1 = new ToolStripMenuItem();
                    menu1.Text   = "open path";
                    menu1.Click += new System.EventHandler((sender1, e1) =>
                    {
                        Process p             = new Process();
                        p.StartInfo.FileName  = "explorer.exe";
                        p.StartInfo.Arguments = @"/e,/select," + selectedNode.Text;
                        p.Start();
                    });

                    ToolStripMenuItem menu2 = new ToolStripMenuItem();
                    menu2.Text   = "open file";
                    menu2.Click += new System.EventHandler((sender1, e1) =>
                    {
                        Process p             = new Process();
                        p.StartInfo.FileName  = "explorer.exe";
                        p.StartInfo.Arguments = selectedNode.Text;
                        p.Start();
                    });

                    ToolStripMenuItem menu3 = new ToolStripMenuItem();
                    menu3.Text   = "delete";
                    menu3.Click += new System.EventHandler((sender1, e1) =>
                    {
                        if (MessageBox.Show("are you sure to delete this file?", "warning", MessageBoxButtons.OKCancel) == DialogResult.OK)
                        {
                            FileInfo file = new FileInfo(selectedNode.Text);
                            file.Delete();
                            selectedNode.Parent.Nodes.Remove(selectedNode);
                        }
                    });
                    this.contextMenuStripTreeNode.Items.Clear();
                    this.contextMenuStripTreeNode.Items.AddRange(new ToolStripItem[] { menu1, menu2, menu3 });
                    this.contextMenuStripTreeNode.Show(MousePosition.X, MousePosition.Y);
                }
                else //fileGroup node selected
                {
                    ToolStripMenuItem menu1 = new ToolStripMenuItem();
                    menu1.Text   = "compute hash";
                    menu1.Click += new System.EventHandler((sender1, e1) =>
                    {
                        List <string> md5list = new List <string>();

                        foreach (TreeNode fileNode in selectedNode.Nodes)
                        {
                            System.Security.Cryptography.MD5 calcer = System.Security.Cryptography.MD5.Create();
                            FileStream fs = new FileStream(fileNode.Text, FileMode.Open);
                            var hash      = calcer.ComputeHash(fs);
                            calcer.Clear();
                            fs.Close();
                            StringBuilder stringBuilder = new StringBuilder();
                            for (int i = 0; i < hash.Length; i++)
                            {
                                stringBuilder.Append(hash[i].ToString("x2"));
                            }
                            md5list.Add(stringBuilder.ToString());
                        }
                        string str = "";
                        foreach (var item in md5list)
                        {
                            str += item + "\r\n";
                        }
                        MessageBox.Show(str);
                    });
                    ToolStripMenuItem menu2 = new ToolStripMenuItem();
                    menu2.Text   = "compare content";
                    menu2.Click += new System.EventHandler((sender1, e1) =>
                    {
                        bool issame = CompareFile(selectedNode.Nodes[0].Text, selectedNode.Nodes[1].Text);
                        MessageBox.Show(issame ? "内容完全一致" : "内容不一致");
                    });

                    this.contextMenuStripTreeNode.Items.Clear();
                    this.contextMenuStripTreeNode.Items.AddRange(new ToolStripItem[] { menu1, menu2 });
                    this.contextMenuStripTreeNode.Show(MousePosition.X, MousePosition.Y);
                }
            }
        }
Exemple #11
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            string hostname = TxtHost.Text.ToLower().Trim();
            string username = TxtUser.Text.ToLower().Trim();
            string password = TxtPass.Text.ToLower().Trim();

            // Try to set the hostname
            if (!Network.GameComms.SetHost(hostname))
            {
                MessageBox.Show(this, "Please check hostname");
            }

            bool is_new_user = (Button)sender == BtnNew;

            if (username.Length > 0 && password.Length > 0)
            {
                output_username = username;
                output_password = password;

                MsgLogin msg = new MsgLogin();
                msg.Action       = (is_new_user) ? MsgLogin.ActionType.NewUser : MsgLogin.ActionType.LoginUser;
                msg.Username     = username;
                msg.PasswordHash = password;

                using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
                {
                    // Convert the password to bytes
                    byte[] pw_bytes   = Encoding.ASCII.GetBytes(output_password);
                    byte[] hash_bytes = md5.ComputeHash(pw_bytes);

                    // Convert the bytes to a hex string
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < hash_bytes.Length; i++)
                    {
                        sb.Append(hash_bytes[i].ToString("x2"));
                    }
                    msg.PasswordHash = sb.ToString();
                }

                try
                {
                    Network.GameComms.ResetSocket();
                }
                catch (System.Net.Sockets.SocketException)
                {
                    MessageBox.Show(this, "Unable to connect to server");
                    return;
                }

                if (chkUseSecure.Checked)
                {
                    if (!Network.GameComms.SetupSSL())
                    {
                        MessageBox.Show(this, "Unable to setup SSL connection");
                        return;
                    }
                }

                Network.GameComms.SendMessage(msg);

                MsgServerResponse msg_response = null;

                for (int i = 0; i < 10; ++i)
                {
                    MsgBase msg_b = Network.GameComms.ReceiveMessage();

                    if (msg_b == null)
                    {
                        Thread.Sleep(100);
                    }
                    else
                    {
                        if (msg_b is MsgServerResponse)
                        {
                            msg_response = (MsgServerResponse)msg_b;
                        }

                        break;
                    }
                }

                if (msg_response != null && msg_response.ResponseCode == ResponseCodes.OK)
                {
                    Network.GameComms.SetPlayer(msg_response.User);
                    DialogResult = DialogResult.OK;
                    Close();
                }
                else
                {
                    MessageBox.Show(this, "Login Failed");
                }
            }
        }
Exemple #12
0
        public static ProcessModuleWow64Safe[] ModulesWow64Safe(this Process p)
        {
            if (ModuleCache.Count > 100)
            {
                ModuleCache.Clear();
            }

            const int LIST_MODULES_ALL = 3;
            const int MAX_PATH         = 260;

            var hModules = new IntPtr[1024];

            uint cb = (uint)IntPtr.Size * (uint)hModules.Length;
            uint cbNeeded;

            if (!WinAPI.EnumProcessModulesEx(p.Handle, hModules, cb, out cbNeeded, LIST_MODULES_ALL))
            {
                throw new Win32Exception();
            }
            uint numMods = cbNeeded / (uint)IntPtr.Size;

            // Create MD5 hash of loaded module pointers, if modules have changed we do the full scan
            System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
            byte[] hashData = new byte[hModules.Count() * sizeof(Int64)];
            for (int i = 0; i < numMods; i++)
            {
                byte[] addrBytes = BitConverter.GetBytes(hModules[i].ToInt64());
                addrBytes.CopyTo(hashData, i * sizeof(Int64));
            }

            byte[] hashResult = md5.ComputeHash(hashData);
            string hashString = BitConverter.ToString(hashResult).Replace("-", string.Empty).ToLower();

            if (ModuleCache.ContainsKey(hashString))
            {
                return(ModuleCache[hashString]);
            }

            // everything below is fairly expensive, which is why we cache!
            var  ret             = new List <ProcessModuleWow64Safe>();
            var  sb              = new StringBuilder(MAX_PATH);
            bool moduleLoadError = false;

            for (int i = 0; i < numMods; i++)
            {
                try
                {
                    sb.Clear();
                    if (WinAPI.GetModuleFileNameEx(p.Handle, hModules[i], sb, (uint)sb.Capacity) == 0)
                    {
                        throw new Win32Exception();
                    }
                    string fileName = sb.ToString();

                    sb.Clear();
                    if (WinAPI.GetModuleBaseName(p.Handle, hModules[i], sb, (uint)sb.Capacity) == 0)
                    {
                        throw new Win32Exception();
                    }
                    string baseName = sb.ToString();

                    var moduleInfo = new WinAPI.MODULEINFO();
                    if (!WinAPI.GetModuleInformation(p.Handle, hModules[i], out moduleInfo, (uint)Marshal.SizeOf(moduleInfo)))
                    {
                        throw new Win32Exception();
                    }

                    ret.Add(new ProcessModuleWow64Safe()
                    {
                        FileName          = fileName,
                        BaseAddress       = moduleInfo.lpBaseOfDll,
                        ModuleMemorySize  = (int)moduleInfo.SizeOfImage,
                        EntryPointAddress = moduleInfo.EntryPoint,
                        ModuleName        = baseName
                    });
                }
                catch (Win32Exception win32Ex)
                {
                    // This exception doesnt need to be propagated up since it is a common occurence for
                    // handles to be invalidated inbetween calls to module functions. If we miss a module
                    // then we'll get it on the next invocation.
                    Log.Error(win32Ex);
                    moduleLoadError = true;
                    break;
                }
            }

            if (!moduleLoadError)
            {
                ModuleCache.Add(hashString, ret.ToArray());
            }

            return(ret.ToArray());
        }
Exemple #13
0
 /// <summary>
 /// Usage:
 /// var md5 = System.Security.Cryptography.MD5.Create();
 /// var md5string = Md5.CalculateMd5(input, md5);
 /// </summary>
 /// <param name="input"></param>
 /// <param name="md5"></param>
 /// <returns></returns>
 public static string CalculateMd5(string input, System.Security.Cryptography.MD5 md5)
 {
     byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
     byte[] hash       = md5.ComputeHash(inputBytes);
     return(ByteArrayToHexViaLookup32(hash));
 }
Exemple #14
0
        /// <summary>
        /// Creates an object
        /// </summary>
        /// <param name="bucketName">Bucket to create object in</param>
        /// <param name="objectName">Key of the new object</param>
        /// <param name="size">Total size of bytes to be written, must match with data's length</param>
        /// <param name="contentType">Content type of the new object, null defaults to "application/octet-stream"</param>
        /// <param name="data">Stream of bytes to send</param>
        public void PutObject(string bucketName, string objectName, Stream data, long size, string contentType)
        {
            if (size >= MinioClient.maximumStreamObjectSize)
            {
                throw new ArgumentException("Input size is bigger than stipulated maximum of 50GB.");
            }

            if (size <= MinioClient.minimumPartSize)
            {
                var bytes = ReadFull(data, (int)size);
                if (bytes.Length != (int)size)
                {
                    throw new UnexpectedShortReadException("Data read " + bytes.Length + " is shorter than the size " + size + " of input buffer.");
                }
                this.PutObject(bucketName, objectName, null, 0, bytes, contentType);
                return;
            }
            var    partSize = MinioClient.minimumPartSize;
            var    uploads  = this.ListIncompleteUploads(bucketName, objectName);
            string uploadId = null;
            Dictionary <int, string> etags = new Dictionary <int, string>();

            if (uploads.Count() > 0)
            {
                foreach (Upload upload in uploads)
                {
                    if (objectName == upload.Key)
                    {
                        uploadId = upload.UploadId;
                        var parts = this.ListParts(bucketName, objectName, uploadId);
                        foreach (Part part in parts)
                        {
                            etags[part.PartNumber] = part.ETag;
                        }
                        break;
                    }
                }
            }
            if (uploadId == null)
            {
                uploadId = this.NewMultipartUpload(bucketName, objectName, contentType);
            }
            int  partNumber   = 0;
            long totalWritten = 0;

            while (totalWritten < size)
            {
                partNumber++;
                byte[] dataToCopy = ReadFull(data, (int)partSize);
                if (dataToCopy == null)
                {
                    break;
                }
                if (dataToCopy.Length < partSize)
                {
                    var expectedSize = size - totalWritten;
                    if (expectedSize != dataToCopy.Length)
                    {
                        throw new UnexpectedShortReadException("Unexpected short read. Read only " + dataToCopy.Length + " out of " + expectedSize + "bytes");
                    }
                }
                System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
                byte[] hash = md5.ComputeHash(dataToCopy);
                string etag = BitConverter.ToString(hash).Replace("-", string.Empty).ToLower();
                if (!etags.ContainsKey(partNumber) || !etags[partNumber].Equals(etag))
                {
                    etag = this.PutObject(bucketName, objectName, uploadId, partNumber, dataToCopy, contentType);
                }
                etags[partNumber] = etag;
                totalWritten     += dataToCopy.Length;
            }

            foreach (int curPartNumber in etags.Keys)
            {
                if (curPartNumber > partNumber)
                {
                    etags.Remove(curPartNumber);
                }
            }
            this.CompleteMultipartUpload(bucketName, objectName, uploadId, etags);
        }
Exemple #15
0
        private string GetHDsid()
        {
            string KeyPw = string.Empty;

            try
            {
                using (System.Management.ManagementClass mc = new System.Management.ManagementClass("Win32_DiskDrive"))
                {
                    string strHardDiskID = string.Empty;
                    foreach (System.Management.ManagementObject mo in mc.GetInstances())
                    {
                        if (mo["Index"].ToString().Trim() == "0")
                        {
                            foreach (System.Management.PropertyData pd in mo.Properties)
                            {
                                bool has = false;
                                switch (pd.Name.Trim())
                                {
                                case "Caption":
                                {
                                    strHardDiskID += mo["Caption"].ToString().Trim();
                                    break;
                                }

                                case "SerialNumber":
                                {
                                    strHardDiskID += mo["SerialNumber"].ToString().Trim();
                                    has            = true;
                                    break;
                                }

                                case "Signature":
                                {
                                    strHardDiskID += mo["Signature"].ToString().Trim();
                                    break;
                                }

                                default:
                                {
                                    break;
                                }
                                }
                                if (has)
                                {
                                    break;
                                }
                            }
                            break;
                        }
                    }
                    strHardDiskID = string.IsNullOrEmpty(strHardDiskID) ? "13816350872" : strHardDiskID;
                    using (System.Security.Cryptography.MD5 md = System.Security.Cryptography.MD5.Create())
                    {
                        KeyPw = BitConverter.ToString(md.ComputeHash(System.Text.Encoding.UTF8.GetBytes(strHardDiskID))).Replace("-", string.Empty);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(KeyPw);
        }
Exemple #16
0
        /// <summary>
        /// Creates an object
        /// </summary>
        /// <param name="bucket">Bucket to create object in</param>
        /// <param name="key">Key of the new object</param>
        /// <param name="size">Total size of bytes to be written, must match with data's length</param>
        /// <param name="contentType">Content type of the new object, null defaults to "application/octet-stream"</param>
        /// <param name="data">Stream of bytes to send</param>
        public void PutObject(string bucket, string key, long size, string contentType, Stream data)
        {
            if (size <= MinioClient.minimumPartSize)
            {
                var bytes = ReadFull(data, (int)size);
                if (bytes.Length != (int)size)
                {
                    throw new UnexpectedShortReadException(bucket, key, size, bytes.Length);
                }
                this.DoPutObject(bucket, key, null, 0, contentType, bytes);
            }
            else
            {
                var    partSize = CalculatePartSize(size);
                var    uploads  = this.ListAllIncompleteUploads(bucket, key);
                string uploadId = null;
                Dictionary <int, string> etags = new Dictionary <int, string>();
                if (uploads.Count() > 0)
                {
                    foreach (Upload upload in uploads)
                    {
                        if (key == upload.Key)
                        {
                            uploadId = upload.UploadId;
                            var parts = this.ListParts(bucket, key, uploadId);
                            foreach (Part part in parts)
                            {
                                etags[part.PartNumber] = part.ETag;
                            }
                            break;
                        }
                    }
                }
                if (uploadId == null)
                {
                    uploadId = this.NewMultipartUpload(bucket, key, contentType);
                }
                int  partNumber   = 0;
                long totalWritten = 0;
                while (totalWritten < size)
                {
                    partNumber++;
                    byte[] dataToCopy = ReadFull(data, (int)partSize);
                    if (dataToCopy == null)
                    {
                        break;
                    }
                    if (dataToCopy.Length < partSize)
                    {
                        var expectedSize = size - totalWritten;
                        if (expectedSize != dataToCopy.Length)
                        {
                            throw new UnexpectedShortReadException(bucket, key, expectedSize, dataToCopy.Length);
                        }
                    }
                    System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
                    byte[] hash = md5.ComputeHash(dataToCopy);
                    string etag = BitConverter.ToString(hash).Replace("-", string.Empty).ToLower();
                    if (!etags.ContainsKey(partNumber) || !etags[partNumber].Equals(etag))
                    {
                        etag = DoPutObject(bucket, key, uploadId, partNumber, contentType, dataToCopy);
                    }
                    etags[partNumber] = etag;
                    totalWritten     += dataToCopy.Length;
                }

                foreach (int curPartNumber in etags.Keys)
                {
                    if (curPartNumber > partNumber)
                    {
                        etags.Remove(curPartNumber);
                    }
                }

                this.CompleteMultipartUpload(bucket, key, uploadId, etags);
            }
        }
Exemple #17
0
        /// <summary>
        /// Creates an object from inputstream
        /// </summary>
        /// <param name="bucketName">Bucket to create object in</param>
        /// <param name="objectName">Key of the new object</param>
        /// <param name="size">Total size of bytes to be written, must match with data's length</param>
        /// <param name="contentType">Content type of the new object, null defaults to "application/octet-stream"</param>
        /// <param name="data">Stream of bytes to send</param>
        /// <param name="cancellationToken">Optional cancellation token to cancel the operation</param>
        /// <param name="metaData">Object metadata to be stored. Defaults to null.</param>
        public async Task PutObjectAsync(string bucketName, string objectName, Stream data, long size, string contentType = null, Dictionary <string, string> metaData = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            utils.validateBucketName(bucketName);
            utils.validateObjectName(objectName);
            if (metaData == null)
            {
                metaData = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            }
            else
            {
                metaData = new Dictionary <string, string>(metaData, StringComparer.OrdinalIgnoreCase);
            }
            if (string.IsNullOrWhiteSpace(contentType))
            {
                contentType = "application/octet-stream";
            }
            if (!metaData.ContainsKey("Content-Type"))
            {
                metaData["Content-Type"] = contentType;
            }
            if (data == null)
            {
                throw new ArgumentNullException("Invalid input stream,cannot be null");
            }

            // for sizes less than 5Mb , put a single object
            if (size < Constants.MinimumPartSize && size >= 0)
            {
                var bytes = ReadFull(data, (int)size);
                if (bytes.Length != (int)size)
                {
                    throw new UnexpectedShortReadException("Data read " + bytes.Length + " is shorter than the size " + size + " of input buffer.");
                }
                await this.PutObjectAsync(bucketName, objectName, null, 0, bytes, metaData, cancellationToken);

                return;
            }
            // For all sizes greater than 5MiB do multipart.

            dynamic multiPartInfo = utils.CalculateMultiPartSize(size);
            double  partSize      = multiPartInfo.partSize;
            double  partCount     = multiPartInfo.partCount;
            double  lastPartSize  = multiPartInfo.lastPartSize;

            Part[] totalParts = new Part[(int)partCount];
            Part   part       = null;

            Part[] existingParts = null;

            string uploadId = await this.getLatestIncompleteUploadIdAsync(bucketName, objectName, cancellationToken);

            if (uploadId == null)
            {
                uploadId = await this.NewMultipartUploadAsync(bucketName, objectName, metaData, cancellationToken);
            }
            else
            {
                existingParts = await this.ListParts(bucketName, objectName, uploadId, cancellationToken).ToArray();
            }

            double expectedReadSize = partSize;
            int    partNumber;
            bool   skipUpload = false;

            for (partNumber = 1; partNumber <= partCount; partNumber++)
            {
                byte[] dataToCopy = ReadFull(data, (int)partSize);

                if (partNumber == partCount)
                {
                    expectedReadSize = lastPartSize;
                }
                if (existingParts != null && partNumber <= existingParts.Length)
                {
                    part = existingParts[partNumber - 1];
                    if (part != null && partNumber == part.PartNumber && expectedReadSize == part.partSize())
                    {
                        System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
                        byte[] hash = md5.ComputeHash(dataToCopy);
                        string etag = BitConverter.ToString(hash).Replace("-", string.Empty).ToLower();
                        if (etag.Equals(part.ETag))
                        {
                            totalParts[partNumber - 1] = new Part()
                            {
                                PartNumber = part.PartNumber, ETag = part.ETag, size = part.partSize()
                            };
                            skipUpload = true;
                        }
                    }
                }
                else
                {
                    skipUpload = false;
                }

                if (!skipUpload)
                {
                    string etag = await this.PutObjectAsync(bucketName, objectName, uploadId, partNumber, dataToCopy, metaData, cancellationToken);

                    totalParts[partNumber - 1] = new Part()
                    {
                        PartNumber = partNumber, ETag = etag, size = (long)expectedReadSize
                    };
                }
            }
            Dictionary <int, string> etags = new Dictionary <int, string>();

            for (partNumber = 1; partNumber <= partCount; partNumber++)
            {
                etags[partNumber] = totalParts[partNumber - 1].ETag;
            }
            await this.CompleteMultipartUploadAsync(bucketName, objectName, uploadId, etags, cancellationToken);
        }
Exemple #18
0
        public DataTable enterVerify(string account, string access_code, out THC_Library.Error error)
        {
            error = null;
            DataTable resultTable = null;

            byte[] pwdBytes = System.Text.Encoding.Default.GetBytes(access_code);
            System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
            pwdBytes = md5.ComputeHash(pwdBytes);
            string strPwd = Convert.ToBase64String(pwdBytes);

            IList <SqlParameter> paraList = new System.Collections.Generic.List <SqlParameter>();
            string strSQL = "select AU001,AU003 from activity_user where AU001=@AU001";

            paraList.Add(new SqlParameter("@AU001", account));

            DataBaseControl dbCtl = new DataBaseControl();

            try
            {
                dbCtl.Open();
                IDataReader dataReader = dbCtl.GetReader(strSQL, paraList);
                if (dataReader.Read())
                {
                    string PWD = dataReader["AU003"].ToString();
                    dataReader.Close();
                    if (PWD != strPwd)
                    {
                        throw new Exception("請輸入正確的密碼");
                    }
                }
                else
                {
                    dataReader.Close();
                    throw new Exception("請輸入正確的帳號");
                }

                strSQL = "update activity_user set AU004=@AU004 where AU001=@AU001";
                paraList.Clear();
                paraList.Add(new SqlParameter("@AU004", DateTime.Now));
                paraList.Add(new SqlParameter("@AU001", account));
                dbCtl.ExecuteCommad(strSQL, paraList);

                if (account == "root.admin")
                {
                    strSQL = "select AU001,AU002,AU004 from activity_user where AU001!='root.admin'";
                    paraList.Clear();
                    resultTable = dbCtl.GetDataTable(strSQL, paraList);
                }
            }
            catch (Exception ex)
            {
                error              = new THC_Library.Error();
                error.Number       = THC_Library.THCException.SYSTEM_ERROR;
                error.ErrorMessage = ex.Message;
            }
            finally
            {
                dbCtl.Close();
            }

            return(resultTable);
        }
Exemple #19
0
        private string DrawSignatureImage(List <Point> Points, string path)
        {
            int    width  = 512;
            int    height = 128;
            Bitmap bmp    = new Bitmap(width, height);

            Graphics g          = Graphics.FromImage(bmp);
            Brush    whiteBrush = new SolidBrush(Color.White);
            Brush    blackBrush = new SolidBrush(Color.Black);
            Pen      p          = new Pen(blackBrush);

            bmp.SetResolution(height / 2, width / 2);
            g.TranslateTransform(0f, height);
            g.ScaleTransform(1f, -1f);
            g.FillRegion(whiteBrush,
                         new Region(new Rectangle(0, 0, width, height)));

            p.Width    = 10;
            p.StartCap = System.Drawing.Drawing2D.LineCap.Round;
            p.EndCap   = System.Drawing.Drawing2D.LineCap.Round;
            p.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;

            List <Point> line = new List <Point>();

            foreach (Point point in Points)
            {
                if (point.IsEmpty)
                {
                    try {
                        g.DrawLines(p, line.ToArray());
                        line.Clear();
                    } catch (Exception) {
                        System.Console.Write("BAD LINE: ");
                        foreach (Point pt in line)
                        {
                            System.Console.Write(pt);
                            System.Console.Write(" ");
                        }
                        System.Console.WriteLine("");
                    }
                }
                else
                {
                    line.Add(point);
                }
            }

            // silly rigamarole to get a unique file name
            System.Security.Cryptography.MD5 hasher = System.Security.Cryptography.MD5.Create();
            System.Text.ASCIIEncoding        enc    = new System.Text.ASCIIEncoding();
            byte[] hash = hasher.ComputeHash(enc.GetBytes(DateTime.Now.ToString()));
            System.Text.StringBuilder sBuilder = new System.Text.StringBuilder();
            for (int i = 0; i < hash.Length; i++)
            {
                sBuilder.Append(hash[i].ToString("x2"));
            }
            string base_fn = path + "\\" + sBuilder.ToString() + ".bmp";

            bmp.Save(base_fn, System.Drawing.Imaging.ImageFormat.Bmp);

            // pass through 1bpp conversion
            byte[] fixbpp = BitmapBPP.BitmapConverter.To1bpp(base_fn);
            System.IO.File.WriteAllBytes(base_fn, fixbpp);

            return(base_fn);
        }
        public static byte[] ComputeHash(byte[] input)
        {
            if (originalHasher != null)
            {
                return(originalHasher.ComputeHash(input));
            }


            // 既存実装が使えなかったら自前実装で計算

            uint a0 = 0x67452301;
            uint b0 = 0xefcdab89;
            uint c0 = 0x98badcfe;
            uint d0 = 0x10325476;

            byte[] inpad = new byte[(int)Math.Ceiling((input.Length + 9) / 64.0) * 64];
            Array.Copy(input, inpad, input.Length);

            // add bit "1"
            inpad[input.Length] = 0x80;
            // add input's length(bits)
            for (int i = inpad.Length - 8; i < inpad.Length - 4; i++)
            {
                inpad[i] = (byte)(((uint)input.Length << 3) >> ((i - (inpad.Length - 8)) * 8));
            }
            inpad[inpad.Length - 4] = (byte)((uint)input.Length >> 29);


            for (int chunk = 0; chunk < inpad.Length / 64; chunk++)
            {
                uint[] m = ToUInt32(inpad, chunk * 64, 16);

                uint a = a0;
                uint b = b0;
                uint c = c0;
                uint d = d0;

                for (int i = 0; i < 64; i++)
                {
                    uint f;
                    int  g;

                    if (i < 16)
                    {
                        f = (b & c) | (~b & d);
                        g = i;
                    }
                    else if (i < 32)
                    {
                        f = (d & b) | (~d & c);
                        g = (5 * i + 1) % 16;
                    }
                    else if (i < 48)
                    {
                        f = b ^ c ^ d;
                        g = (3 * i + 5) % 16;
                    }
                    else
                    {
                        f = c ^ (b | ~d);
                        g = 7 * i % 16;
                    }

                    uint dtemp = d;
                    d  = c;
                    c  = b;
                    b += RotateLeft((a + f + k[i] + m[g]), s[i]);
                    a  = dtemp;
                }

                a0 += a;
                b0 += b;
                c0 += c;
                d0 += d;
            }

            return(ToBytes(a0, b0, c0, d0));
        }
Exemple #21
0
 byte[] ComputeMd5Hash(byte[] data)
 {
     return(_md5Algorithm.ComputeHash(data));
 }
Exemple #22
0
 public static byte[] Hash(byte[] value)
 {
     System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
     return(md5.ComputeHash(value));
 }
Exemple #23
0
 public static Guid HashGuid(string uniqueString)
 {
     System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
     byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(uniqueString));
     return(new Guid(hash));
 }
Exemple #24
0
 private string CreateMD5(string input)
 {
     byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
     return(BitConverter.ToString(md5.ComputeHash(inputBytes)).Replace("-", ""));
 }
Exemple #25
0
 private void ComputeStreamHash()
 {
     byte[] hash = _md5.ComputeHash(_stream);
     SetHash(hash);
 }
Exemple #26
0
        public static void Main(String[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine(String.Format("Usage: {0} <extension|url> <progid>", System.Reflection.Assembly.GetExecutingAssembly().GetName().Name));
                return;
            }

            try
            {
                String extension = args[0];
                String progid    = args[1];

                String regpath;
                if (extension.StartsWith("."))
                {
                    regpath = String.Format("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\{0}\\UserChoice", extension);
                }
                else
                {
                    regpath = String.Format("SOFTWARE\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\{0}\\UserChoice", extension);
                }

                Registry.CurrentUser.DeleteSubKey(regpath, false);
                RegistryKey regnode = Registry.CurrentUser.CreateSubKey(regpath);

                System.Security.Principal.WindowsIdentity user = System.Security.Principal.WindowsIdentity.GetCurrent();
                String sid = user.User.Value;

                long ftLastWriteTime;
                RegQueryInfoKey(regnode.Handle.DangerousGetHandle(), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, out ftLastWriteTime);
                DateTime time = DateTime.FromFileTime(ftLastWriteTime);
                time            = time.AddTicks(-(time.Ticks % 600000000));         //clamp to minute part (1min=600000000*100ns)
                ftLastWriteTime = time.ToFileTime();

                String regdate = ftLastWriteTime.ToString("x16");

                String experience = "user choice set via windows user experience {d18b6dd5-6124-4341-9318-804003bafa0b}";

                //Step1: String (Unicode with 0 terminator) from the following: extension, user sid, progid, last modification time for the registry node clamped to minute part, secret experience string
                //Step2: Lowercase
                byte[] bytes = Encoding.Unicode.GetBytes((extension + sid + progid + regdate + experience + "\0").ToLower());
                System.Security.Cryptography.MD5 md5Hash = System.Security.Cryptography.MD5.Create();
                //Step3: MD5
                byte[] md5 = md5Hash.ComputeHash(bytes);
                //Step4: Microsoft hashes from data and md5, xored together
                byte[] mshash1  = sub_1(bytes, md5);
                byte[] mshash2  = sub_2(bytes, md5);
                byte[] finalraw = xorbytes(mshash1, mshash2);
                //Step5: Base64
                String hash = System.Convert.ToBase64String(finalraw);

                regnode.SetValue("ProgId", progid);
                regnode.SetValue("Hash", hash);

                Console.WriteLine("Success");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error during operation:");
                Console.WriteLine(ex.Message);
            }
        }
Exemple #27
0
 public string ComputeDataHash(ref byte[] data)
 {
     using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
         return(BitConverter.ToString(md5.ComputeHash(data)));
 }
Exemple #28
0
 /// <summary>
 /// 对字符串进行md5加密
 /// </summary>
 /// <param name="str">需要进行md5演算的字符串</param>
 /// <param name="charEncoder">
 /// 指定对输入字符串进行编解码的 Encoding 类型
 /// </param>
 /// <returns>长度16 的 byte[] 数组</returns>
 protected static byte[] md5raw(string str, Encoding charEncoder)
 {
     System.Security.Cryptography.MD5 md5 =
         System.Security.Cryptography.MD5.Create();
     return(md5.ComputeHash(charEncoder.GetBytes(str)));
 }
Exemple #29
0
 private string GetMd5(string str)
 {
     System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
     return(BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(str))).Replace("-", null).ToLower());
 }
Exemple #30
0
 /// <summary>
 /// Computes the MD5 hash value for the specified byte array.
 /// </summary>
 /// <param name="bytes">The input to compute the hash code for.</param>
 /// <returns>The computed hash code as GUID.</returns>
 /// <remarks>
 /// One instance of the MD5 Crypto Service Provider
 /// can't operate properly with multiple simultaneous threads.
 /// Use lock to solve this problem.
 /// </remarks>
 public static Guid ComputeMd5Hash(byte[] bytes)
 {
     byte[] hash;
     lock (HashProviderLock)
     {
         HashProvider = HashProvider ?? new System.Security.Cryptography.MD5CryptoServiceProvider();
         hash = HashProvider.ComputeHash(bytes);
     }
     return new Guid(hash);
 }
        public async Task CheckNewVersionAsync(bool manual = false)
        {
            string availableVersionResponse = await mainLink.HttpClientController.DownloadFileToStringAsync("https://deltaconnected.com/arcdps/x64/d3d9.dll.md5sum");

            string availableVersion = availableVersionResponse.Split(' ')[0];

            if ((availableVersion != "") && (File.Exists($@"{GW2Location}\bin64\d3d9.dll")))
            {
                using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
                {
                    try
                    {
                        if (File.Exists($@"{GW2Location}\bin64\d3d9.dll"))
                        {
                            byte[] hash = null;
                            using (FileStream stream = File.OpenRead($@"{GW2Location}\bin64\d3d9.dll"))
                            {
                                hash = md5.ComputeHash(stream);
                            }
                            if (!BitConverter.ToString(hash).Replace("-", "").ToLower().Equals(availableVersion))
                            {
                                buttonCheckNow.Enabled   = false;
                                groupBoxUpdating.Enabled = true;
                                if (manual)
                                {
                                    DialogResult result = MessageBox.Show("New arcdps version available.\nDo you want to download the new version?", "arcdps version checker", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                                    if (result.Equals(DialogResult.Yes))
                                    {
                                        await UpdateArcAsync();
                                    }
                                }
                                else
                                {
                                    if (Properties.Settings.Default.ArcAutoUpdate)
                                    {
                                        await UpdateArcAsync();
                                    }
                                    else
                                    {
                                        mainLink.ShowBalloon("arcdps version checking", "New version of arcdps available.\nGo to arcdps version checking settings to use the auto-update.", 8500);
                                    }
                                }
                            }
                            else
                            {
                                if (manual)
                                {
                                    MessageBox.Show("arcdps is up to date.", "arcdps version checker", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                        }
                        else
                        {
                            buttonCheckNow.Enabled   = false;
                            groupBoxUpdating.Enabled = true;
                            if (manual)
                            {
                                DialogResult result = MessageBox.Show("New arcdps version available.\nDo you want to download the new version?", "arcdps version checker", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                                if (result.Equals(DialogResult.Yes))
                                {
                                    await UpdateArcAsync();
                                }
                            }
                            else
                            {
                                mainLink.ShowBalloon("arcdps version checking", "New version of arcdps available.\nGo to arcdps version checking settings to use the auto-update.", 8500);
                            }
                        }
                    }
                    catch
                    {
                        if (manual)
                        {
                            MessageBox.Show("There has been an error trying to check if arcdps is up to date.", "arcdps version checker", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            else
            {
                buttonCheckNow.Enabled   = false;
                groupBoxUpdating.Enabled = true;
                if (manual)
                {
                    DialogResult result = MessageBox.Show("New arcdps version available\nDo you want to download the new version?", "arcdps version checker", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (result.Equals(DialogResult.Yes))
                    {
                        await UpdateArcAsync();
                    }
                }
            }
        }