Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2012
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10. using System.Net;
  11.  
  12. namespace BattlEye
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public Form1()
  17. {
  18. InitializeComponent();
  19. }
  20.  
  21. private void button1_Click(object sender, EventArgs e)
  22. {
  23. string path1 = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
  24. string path2 = path1 + "\\AppData\\Local\\ArmA 2 OA\\BattlEye\\BEClient.dll";
  25. string beClientMD5;
  26. string beHash;
  27. TextReader tr = new StreamReader("md5hash.txt");
  28. beClientMD5 = tr.ReadLine();
  29. tr.Close();
  30. beHash = GetMD5HashFromFile(path2);
  31. beStatus.Text = Status(beHash, beClientMD5);
  32. }
  33.  
  34. private static string GetMD5HashFromFile(string fileName)
  35. {
  36. FileStream file = new FileStream(fileName, FileMode.Open);
  37. System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
  38. byte[] retVal = md5.ComputeHash(file);
  39. file.Close();
  40.  
  41. StringBuilder sb = new StringBuilder();
  42. for (int i = 0; i < retVal.Length; i++)
  43. {
  44. sb.Append(retVal[i].ToString("x2"));
  45. }
  46. return sb.ToString();
  47. }
  48.  
  49. public static string Status(string md5, string beclientmd5)
  50. {
  51. Form1 form = new Form1();
  52. if (md5 == beclientmd5)
  53. {
  54. return "Up to date!";
  55. }
  56. else
  57. {
  58. return "Wrong version!";
  59. }
  60. }
  61.  
  62. private void Form1_Load(object sender, EventArgs e)
  63. {
  64. WebClient webClient = new WebClient();
  65. webClient.DownloadFile("http://dl.dropbox.com/u/95266139/md5hash.txt", "md5hash.txt");
  66. }
  67.  
  68. private void button2_Click(object sender, EventArgs e)
  69. {
  70. try
  71. {
  72. string path1 = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
  73. string path2 = path1 + "\\AppData\\Local\\ArmA 2 OA\\BattlEye\\BEClient.dll";
  74. WebClient webClient = new WebClient();
  75. webClient.DownloadFile("http://dl.dropbox.com/u/95266139/BEClient.dll", path2);
  76. }
  77. catch (Exception ex)
  78. {
  79. MessageBox.Show(ex.ToString());
  80. }
  81. }
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement